摘要: 一、在application中注册消息监听public class BackgroundServiceApplication extends Application { @Override public void onCreate() { super.onCreate(); //该广播注册后可每分钟发送一次该广播,用来判断service的状态,是否进行重新启动。 //此action只能通过动态注册 IntentFilter intentFilter = new IntentFilter(Intent.ACTION_TIME_T... 阅读全文
posted @ 2013-08-07 17:30 似水流云 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2013-08-07 16:07 似水流云 阅读(489) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2013-08-07 16:05 似水流云 阅读(1032) 评论(0) 推荐(0) 编辑