2015-04-23 42 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!泰... –