0
我試過這個喚醒示例:https://github.com/commonsguy/cw-omnibus/tree/master/AlarmManager/WakefulAlarmManager和WakeLock示例
但我有幾個問題。
我需要<action android:name="android.intent.action.BOOT_COMPLETED" />
?因爲我的測試意圖總是爲空。
而且inScheduledService是:
@Override
protected void doWakefulWork(Intent intent) {
Log.d(getClass().getSimpleName(), "I ran!");
}
但這種方法從來沒有發射。
在WakefulintentService有這種方法,這也是從來沒有發射:
@Override
final protected void onHandleIntent(Intent intent) {
try {
doWakefulWork(intent);
} finally {
PowerManager.WakeLock lock = getLock(this.getApplicationContext());
if (lock.isHeld()) {
lock.release();
}
}
}
什麼改變,這樣我會得到I ran
作爲輸出?