Is there an Android API for removing alarms

I have an application that allows the user to set alarms at different times. It currently uses AlarmManager plus BroadcastReceiver and AlertDialog to alert the user of an alarm.

I would like to see if my application can use the built-in alarm. I know that I can set the alarm in this way:

Intent i = new Intent(AlarmClock.ACTION_SET_ALARM); i.putExtra(AlarmClock.EXTRA_HOUR, new Date(alarm.getTime()).getHours()); i.putExtra(AlarmClock.EXTRA_MINUTES, new Date(alarm.getTime()).getMinutes()); i.putExtra(AlarmClock.EXTRA_MINUTES, alarm.getDescription()); i.putExtra(AlarmClock.EXTRA_SKIP_UI, true); context.startActivity(i); 

but this creates two problems:

  • There seems to be no way to schedule an alarm for> 24 hours in the future.
  • The built-in alarm in Android only allows you to configure 10 alarms

As work on point 1, I could use AlarmManager to set an alarm for users within 24 hours. However, this leaves me with point 2 - ideally, I need a way to remove the alarm from the Android alarm after they have been executed (to avoid triggering alarms in the application), but cannot find the list of alarms and delete them.

Is this possible, or do I need to stick with the manual AlarmManager / AlertDialog approach?

+6
source share
1 answer

If you need an alarm within 24 hours, you can use an alarm. If in the future you will need to add a calendar event notification. You can also make your own implementation of the alarm manager, all about what you are trying to achieve, about which you did not say anything.

0
source

Source: https://habr.com/ru/post/916857/


All Articles