1
我使用WakeLock在後臺啓動服務,下班後停止服務並釋放WakeLock。但我不知道正確的順序。它工作正常,但我總是得到錯誤:使用WAKE_LOCK停止服務
10-13 14:48:23.320: A/PowerManager(20951): WakeLock finalized while still held: AppService
以下是我的代碼snippset:
PowerManager pm = (PowerManager)getApplicationContext().getSystemService(Context.POWER_SERVICE);
WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
wl.acquire();
工作完成後,停止一切,但以何種順序:
stopForeground(true);
wl.release();
stopSelf();
感謝它的工作! – user1390816