SetInterval equivalent in Android / Java?

I want to be able to start a service that checks from a remote server at predefined intervals. How will I do this in Android? Example: a user sets a parameter that they want to check for updates every 10 minutes, how would this be done?

+5
source share
1 answer

you can use a handler for this, for example

Handler handler = new Handler();

private Runnable updateData = new Runnable(){
    public void run(){
         //call the service here
         ////// set the interval time here
         handler.postDelayed(updateData,10000);
    }
}

you can set the user definition time in the postDelayed () method

here's the link

http://developer.android.com/reference/android/os/Handler.html

http://www.vogella.de/articles/AndroidPerformance/article.html

http://www.tutorialforandroid.com/2009/01/using-handler-in-android.html

http://www.satyakomatineni.com/akc/display?url=DisplayNoteIMPURL&reportId=3496

http://www.helloandroid.com/taxonomy/term/43

+14

All Articles