0

My app shows the user a way to schedule some work(background heavy work). and I want to do it in foreground service at midnight(or some other time that chooses by the user).

  • If your work can be done within 10 mins, you can use workManager (If device was not in doze mode) and you don't need a service. But if it is more... – Mahdi-Malv Jul 09 '19 at 10:25

2 Answers2

0

I think the Android Jetpack component called WorkManager is for you :

documentation : https://developer.android.com/topic/libraries/architecture/workmanager

codelab : https://codelabs.developers.google.com/codelabs/android-workmanager/#0

diAz
  • 478
  • 4
  • 16
0

I recomend using work manager instead. Its more suited for such task, and is more modern aproach to background processing which with new android devices become more limited (by doze mode, etc.).

If you need to schedule your work at specified time then you schould rather choose AlarmManager - see this so: Schedule a work on a specific time with WorkManager

marcinj
  • 48,511
  • 9
  • 79
  • 100