2

I need my app to open at a scheduled time. I've searched for the best way of doing this and have got quite confused. I'm currently using BroadcastReceiver to respond to onBoot. That works fine but which way is best to go next? Should I set up an AsyncTask ..or.. should I set up a Service. Then should I use AlarmManager or a TimerTask to trigger the Main activity to start? Or should I even use AlarmManager/TimerTask in the BroadcastReceiver? Which course would be best practice and why?

Tenten Ponce
  • 2,436
  • 1
  • 13
  • 40
Amos Fox
  • 308
  • 1
  • 10

1 Answers1

0

If exact precision is not required, use AlarmManager as this will have the least user impact. Otherwise, I would personally use a service. One case to consider is that the user may open the app and navigate to another activity before your time. Also, the user could open your app and leave again before the time.

Hack5
  • 3,244
  • 17
  • 37
  • Precision is fairly important, to within a few seconds anyway. If I get the BroadcastReceiver to trigger a service then, should I get that service to run a TimerTask? Then once the task runs I can check if the phone needs waking, if the app is already running etc. – Amos Fox Dec 31 '17 at 17:49