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. When will google post official cupcake SDK

Even a "beta" SDK would be helpful. There are lots of app developers who
don't necessarily know how to build cupcake from the GIT. Given that HTC
Magic (based on cupcake, I heard) is rolling out real soon now, wouldn't it
be nice to give the app developers a chance to test if their app is
compatible with cupcake?

Sure, Android API is supposed to be backwards compatible. However, there are
quite a few bugs in the G1 that I had to work around with ugly hacks. Now I
start to worry if those hacks would break on cupcake.

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

2. ADT Layout Editor -- What do warning triangles mean?

Is there an explanation of the ADT layout editor UI some place? I
can't find anything on the Android web site about it. When I look at a
layout in the design view, there are a number of fields at the top
with labels like MCC, MNC, Lang, etc. I've noticed that I can change
the contents of these fields, such as orientation, and it has an
effect on the view. But a yellow warning triangle appears next to the
field I've changed and the next time I open this view I see the
unmodified field. For example, if I change to landscape orientation
the view goes back to default next time. Is there documentation some
place on what these fields mean and how they are supposed to be used?

-- Jon Webb

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

3. Sorry if I've missed this somewhere, but what is the default thread stack size in Android...

4. Apps labeled as Tetris Clones removed from Android Market

5. How-to start service automatically on system startup and on installation

6. EditText widget - number entry problem

7. RFC compliance