I am wondering will the alarm that I have set get destroyed after i shutting down the device or will it save the state of the schedule and broadcast straightaway when the user turning back on the device as long as the scheduled time is before the current time.
Asked
Active
Viewed 588 times
0
-
Possible duplicate of [does Alarm Manager persist even after reboot?](http://stackoverflow.com/questions/12034357/does-alarm-manager-persist-even-after-reboot) – Mike M. May 02 '16 at 05:15
-
http://stackoverflow.com/a/12034402/3981656 – Sathish Kumar J May 02 '16 at 05:25
3 Answers
3
When device get rebooted alarm manager get destroyed.you need to re register the alarm manager after boot complete
add this permission in your manifest
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
and broadcast
<receiver
android:name="your package name.MyBroadcast "
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
create a broadcast receiver
public class MyBroadcast extends BroadcastReceiver {
private static final String LOG_TAG = "MyBroadcast ";
public MyBroadcast () {
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null) {
String action = intent.getAction();
switch (action) {
case Intent.ACTION_BOOT_COMPLETED:
// Register your alarm manager here
break;
default:
break;
}
}
}
}

Ashutosh Singh
- 260
- 1
- 13
1
Android: Will AlarmManager
gets killed after shutdown ?
Ans: YES
will it save the state of the schedule and broadcast straightaway when the user turning back on the device as long as the scheduled time is before the current time ?
Ans: NO
Resolution: Re-Register AlarmManager
on BOOT_COMPLETED
broadcast

dharmendra
- 7,835
- 5
- 38
- 71
0
It willl be destroyed after shutdown. Your should implement a RECEIVE_BOOT_COMPLETED broadcast receiver. In this way you will when device is shutdown and in your receiver set your AlarmManager again.

Alikbar
- 685
- 6
- 20