ブロードキャスト レシーバーでウェイク ロックを取得して、目覚まし時計アプリケーションで携帯電話をスリープ状態から復帰させようとしています。以下のコードの次の行でクラッシュします。
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
何が起こっているのですか?これを行うより良い方法はありますか?ありがとう!
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
public class RepeatingAlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
AlarmAlertWakeLock.acquireCpuWakeLock(context);
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag");
wl.acquire();
}
}