How To give notifications on Android on specific time in Android Oreo?

后端 未结 2 1938
误落风尘
误落风尘 2020-12-31 11:55

I am looking for a way to create a preference in Settings to send a notification at a specific time of the day (set by user in settings) in an Andr

2条回答
  •  佛祖请我去吃肉
    2020-12-31 12:32

    There are tons of examples of how to do this on StackOverflow, but unfortunately none of them work anymore because Google changed how the AlarmManager works.

    • Android 6: Doze
    • Android 7: Aggressive Doze [Disables CPU shortly after screen is turned OFF]
    • Android 8: Additional restrictions on background services

    The only AlarmManager option that allows a developer to wakeup a device at a specific time is AlarmManager.setAlarmClock.

    Using setAlarmClock

    In addition to the alarm, you can set an intent that will enable you to launch your app when the alarm is clicked.

    The device can also be awoken at a specific time using a high priority FCM, Firebase Cloud Message.

    But in summary, there is no other option: 'setExact' and associated methods no longer work as the name advertises.

提交回复
热议问题