RTC_WAKEUP is not working

前端 未结 4 1155
太阳男子
太阳男子 2021-02-06 17:12

Currently i am working on a Broadcast Receiver application, in which i am making an Alarm which should display a message after we enter the seconds. I used RTC_WAKEUP, which mea

4条回答
  •  春和景丽
    2021-02-06 17:35

    Checked the google DeskClock app: com.android.deskclock.alarms.AlarmStateManager (it's a BroadcastReceiver)

    In its onReceive function used goAsync():

    @Override
    public void onReceive(final Context context, final Intent intent) {
        final PendingResult result = goAsync();
        final PowerManager.WakeLock wl = AlarmAlertWakeLock.createPartialWakeLock(context);
        wl.acquire();
        AsyncHandler.post(new Runnable() {
            @Override
            public void run() {
                handleIntent(context, intent);
                result.finish();
                wl.release();
            }
        });
    }
    

    You should take a shot with that.

提交回复
热议问题