As here described the usual class WakefulBroadcastReceiver is deprecated.
So, now this is not possible to create a scheduled tasks like for previous SDK releases. Google says, I have to use
https://developer.android.com/reference/android/app/job/JobScheduler.html
But how?
So, what's the most useful solution for background scheduled tasks nowadays?
Is AlarmManager not longer useful?
My application wakes up several times a day and updates the notifications using AlarmManager. I'm not really sure what I have to change. What I have to implement? The old API and a new one? Or only up-to-date solution?
WakefulBroadcastReceiverhas never been the sole option for this. For example, myWakefulIntentServicedates back to 2009. And theJobIntentServiceadded to the support library supplants both of those.Um,
JobScheduleris covered in the JavaDocs and elsewhere in the documentation, as well as books and courses on Android app development.That depends entirely upon how you want to define "useful", and I don't know your definition.
Generally speaking:
Use
JobSchedulerwhere possibleUse
setAlarmClock()onAlarmManagerif you are writing an alarm clock appUse the other
set...()methods onAlarmManagerfor backwards compatibility for pre-Android 5.0 devices, perhaps via a wrapper library (e.g., Evernote'sandroid-job)Use push messaging (e.g., FCM) where practical and if you are in position to be dependent upon that push messaging solution
Doing any sort of periodic background work is "no longer useful" for some definitions of "useful". Doze mode and app standby, introduced in Android 6.0, basically make periodic background work unreliable from the user's standpoint.
It is impossible to answer that in the abstract. There is nothing in Android 8.0, or the support library, that prevents you from using
AlarmManageras you have been.