Android AlarmManagerAndroid AlarmManager allows you to access system alarm. By the help of Android AlarmManager in android, you can schedule your application to run at a specific time in the future. It works whether your phone is running or not. The Android AlarmManager holds a CPU wake lock that provides guarantee not to sleep the phone until broadcast is handled. Android AlarmManager ExampleLet's see a simple AlarmManager example that runs after a specific time provided by user. activity_main.xmlYou need to drag only a edittext and a button as given below. File: activity_main.xml
Activity classThe activity class starts the alarm service when user clicks on the button. File: MainActivity.java
Let's create BroadcastReceiver class that starts alarm. File: MyBroadcastReceiver.java
File: AndroidManifest.xml
You need to provide a receiver entry in AndroidManifest.xml file. Let's see the full code of AndroidManifest.xml file. Output:![]() ![]() ![]()
Next TopicAndroid Preferences Example
|
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week