Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android app How to delay your Service start on phone boot

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
        }
}
like image 867
Erik Avatar asked Dec 30 '10 11:12

Erik


1 Answers

use Timer() and TimerTask():

        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                //run your service
            }
        }, 60000);
like image 128
Vladimir Ivanov Avatar answered Sep 27 '22 17:09

Vladimir Ivanov