Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service Timer Notification

HI!

I want make service in OnCreate(), and every five minute, the service show notification..

can you show me about it??

thanks before :)

like image 701
Vootsugu Avatar asked Jun 16 '26 14:06

Vootsugu


1 Answers

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 launching the TimerTask for first time:

postDelayed(mTask, INITIAL_DELAY);

You can find some information in this android article

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

like image 51
Pedro Fraca Avatar answered Jun 18 '26 04:06

Pedro Fraca



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!