摘要:
一、在application中注册消息监听public class BackgroundServiceApplication extends Application { @Override public void onCreate() { super.onCreate(); //该广播注册后可每分钟发送一次该广播,用来判断service的状态,是否进行重新启动。 //此action只能通过动态注册 IntentFilter intentFilter = new IntentFilter(Intent.ACTION_TIME_T... 阅读全文
摘要:
1.显示系统当前所有运行服务:ActivityManager am = (ActivityManager) MainActivity.this.getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : am.getRunningServices(Integer.MAX_VALUE)) { System.out.println(service.service.getPackageName()+"-----"+service.service.getClassName... 阅读全文
摘要:
1.首先继承一个broadcastreceiverpublic class ConnectBroadCastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){ Intent bootActivityIntent=new Intent(context,MainActi... 阅读全文