2015-04-23 38 views
0

我有一个服务每隔5分钟左右就会关闭......我如何查询android以查看此服务何时以编程方式关闭?查询我的服务何时会在Android中运行?

<!-- Send Census Service --> 
    <service android:name="services.scheduled.SendCensusScheduledService" 
      android:icon="@drawable/ic_launcher" 
      android:label="SyncServerDataScheduledService" /> 
    <receiver android:name="services.receivers.SendCensusScheduledServiceReceiver" > 
     <intent-filter> 
      <action android:name="ReceiptBucketClient.android.action.broadcast"/> 
      <action android:name="android.intent.action.BOOT_COMPLETED" /> 
     </intent-filter> 
    </receiver> 
    <receiver android:name="services.receivers.StartSendCensusScheduledServiceReceiver" /> 
+0

做我的,你的答案帮助吗? –

回答

0

检查由PendingIntent

PendingIntent intent = PendingIntent.getBroadcast(context, 0, 
     new Intent("ReceiptBucketClient.android.action.broadcast"), 
     PendingIntent.FLAG_NO_CREATE; 

if (intent != null) { 
    // you have the service scheduled. Cancel it! 
    intent.cancel(); 
} 

记住only the original application owning a PendingIntent can cancel it.

+0

这帮助了很多Deividi Cavarzan!泰... –