1

我看到如果我将跟踪传递给 onStartCommant 的 startIds,那么我可以使用最后一个来停止服务。如果我使用不是最后一个的 starttId 调用 stopSelfResult,那么服务将不会终止。

那么问题是如何在现实生活中使用 stopSelfResult 呢?

4

1 回答 1

1

See AOSP packages/apps/Mms/src/com/android/mms/transaction/SmsReceiver.java

 86     /**
 87      * Called back by the service when it has finished processing notifications,
 88      * releasing the wake lock if the service is now stopping.
 89      */
 90     public static void finishStartingService(Service service, int startId) {
 91         synchronized (mStartingServiceSync) {
 92             if (mStartingService != null) {
 93                 if (service.stopSelfResult(startId)) {
 94                     mStartingService.release();
 95                 }
 96             }
 97         }
 98     }
于 2013-04-10T04:47:38.543 回答