Is there any way to check if an alarm is already set?

前端 未结 4 947
情深已故
情深已故 2020-12-08 00:41

I am stuck. When my application starts I want to check if an alarm is alive that I previously set. If not then I want to set it.

I referred to this solution. I am

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 01:14

    • First alarm will not work when you reboot your android device.
    • You can use the boolean shared preferences to check the alarm is created or not.
    • Android pending intent use the Unique ID

      int REQUEST_CODE=2344; // Unique ID  
      PendingIntent pIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, PendingIntent.FLAG_NO_CREATE);

    you have to use the Boot Receiver broadcast when system reboot then create again alaram with the same request code REQUEST_CODE=2344;

提交回复
热议问题