Alarm Manager - Cancelling all alarms created by application

by Siju Mathew » Sat, 03 Oct 2009 19:14:52 GMT


Sponsored Links
 Hi All,

In my application I create different alarms as reminders, I want to
give a feature to cancel all active alarms. Is there a way to do this
with one call?

I create alarms in the following way:

PendingIntent sender = PendingIntent.getBroadcast(
                                        getApplicationContext(), 
uniqueCodeForAlarm, intent,
PendingIntent.FLAG_ONE_SHOT);

uniqueCodeForAlarm - is a unique code I give as reqesterCode so that I
can create a separate alarm each time. If I did not use this, Alarm
Manager cancels previous alarm. Other option I could use is to make my
intent unique, but I think effect is same for the issue that I have.

The only way I know to cancel an alarm is to use the same Intent again
in a call to AlarmManager.cancel(PendingIntent) method. Because I made
my PendingIntent unique (by requesterCode or by making intent unique),
I a forced to cancel each alarm.

The main issue I have is that I do not store the created alarm's
uniqueCodeForAlarm in database/store. I do not want to store the alarm
in database just because I want to cancel it. It will be uch easier to
query the AlarmManager to get all pending alarms created by my
application, or atleast filter the intent.

For example if I can create an Intent with only the Receiver class, it
should cancel all alarms that match the receiver.

Is there any way to cancel all alarms or retrieve all alarms created
by my application?

Regards,
Siju Mathew

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Asus EEE Pad Transformer

Ehem...
Huahaha

Loe jual rupanya...
Barang gw msh blm jelas nih :)

Kalau boleh tau,brp loe jual?
Ada docking nya gak?
On May 13, 2011 10:53 AM, "Hamdiy Hopequot; <hadi.akbar.m....@gmail.com>


docking.*

-- 
"

2. Develop apps on-the-fly?

Hey there,

I'm wondering whether I should move to developing android apps. As I
know next to nothing on android, I'd like to know if there is a way to
do the developing on an actual android device, or whether I'd be
necessary to get a SDK on an external machine as it seems to be done.
So again: is it possible or in any case convenient to do app
developing on android itself?

Cheers

-- 

3. Camera JavaScript API

4. custom searchbar background color

5. Need help, in case of accessing STARRED contacts

6. Arabic Language Support

7. IWindowManager Hard Key Blocking/Mapping