Search code examples
androidoperating-systemalarmmanager

Schedule AlarmManager Android


Can I schedule alarm manager (.set() methode) in android to a time which is one month later the current time will it be alive for that mutch of time ? what will be the OS effects on this alarmManager ?


Solution

  • Tip for a case when user reboots his phone. You can declare BroadcastReceiver with the following intent-filter:

    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
    

    and re-schedule your alarm in onReceive(...) of your receiver class. Intent will be delivered to the receiver after user reboots his phone. Don't forget to add the following permission to your manifest file:

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    

    Or you can use the library that will handle such cases for you: https://github.com/commonsguy/cwac-wakeful