You are here
Home > Android > Android AlarmManager to Start Background Service Periodically

Android AlarmManager to Start Background Service Periodically

Hello Friends, Today I am going to share how to use Android AlarmManager to Start Background Service Periodically. The Alarm Manager holds a CPU wake lock which guarantees that the phone will not sleep until you have finished handling the broadcast. It can also be used to perform some repetitive task outside the lifetime of your application, which means even if your app is not running, you can initiate long-running operation. such as downloading weather forecast once a day or once every fifteen minutes.

So, here is the code

MainActivity.java

activity_main.xml

MyService.java

AndroidManifest.xml

Screenshot

alarm-manager-test-2 alarm-manager-test-1

AndroidStudio Project Download

Reference

https://developer.android.com/training/scheduling/alarms

Thanks for Stoping by
If you find this helpful then please share

Rajesh Kumar Sahanee
I am a passionate Java Developer and I like Computer Programming. I love to do some interesting experiments and listening music in my free time.
https://www.zatackcoder.com

Comments

zatackcoder
Top