Reputation: 5119
hi When my app get the ACTION_BOOT_COMPLETED it starts a service. I would like to delay that for lets say 60sec. Can i do that in the:
public class StartAtBootServiceReceiver extends BroadcastReceiver
{
public void onReceive(Context context, Intent intent)
{
// Delay...60sec
}
}
Upvotes: 5
Views: 4423
Reputation: 5675
When you receive the BOOT_COMPLETED intent you should use the AlarmManager to setup an pending intent that will fire after 60 seconds.
Upvotes: 2
Reputation: 43098
use Timer()
and TimerTask()
:
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
//run your service
}
}, 60000);
Upvotes: 4