In my app there is a Service
that is intended to run constantly in background once started. This service is started from an Activity
and this is the onStartCommand()
method:
MyService:
....
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(Intent intent, int flags, int startId)
mHandler.postDelayed(new myRunnable(), scheduledTime);
}
I want to know if having a very big scheduledTime
(lets say a couple of days in milliseconds), the Handler
will still execute the Runnable
?
Or should I better use the AlarmManager
for this?
Thanks.
I want to know if having a very big scheduledTime variable (lets say it represents a couple of days), the handler will still execute the runnable?
Yes, if the service and the thread the Handler
posts to will be alive by the time.
Or should I better use the AlarmManager for this?
Yes.