Service Timer Notification

Hi!

I want to make a service in OnCreate (), and a service notification is shown every five minutes.

Can you show me about this?

thanks before :)

+3
source share
1 answer

You can use the TimerTask class with the postDelayed method.

private TimerTask mTask = new TimerTask() {
        @Override
        public void run() {
            //Whatever you want
          postDelayed(this, REPEAT_INTERVAL);   // rinse and repeat...
        }
    };

And in your OnCreate, launch TimerTask for the first time:

postDelayed(mTask, INITIAL_DELAY);

You can find some information in this article in android

http://developer.android.com/resources/articles/timed-ui-updates.html

+2
source

Source: https://habr.com/ru/post/1778052/


All Articles