Squagem
Squagem

Reputation: 734

Implementing unique alarms without creating my own alarm clock application

I have asked this question before (here), however it received no attention and I feel like this could really prove as useful to those who chose to embark on a similar issue.

Basically, I am implementing an application that sets alarms for the user, and in my current attempt I am using the ACTION_SET_ALARM intent to set the system alarm. Now this works fine with one exception: whenever I set an alarm, it makes a brand new alarm until eventually the alarm database is utterly filled with redundant alarms.

I'm trying to figure out how to set UNIQUE alarms without having to completely design my own alarm clock application. There must be a way to do this, simply by utilizing some feature of the native Android alarmclock class.

Methods I have employed thus far:

The last remaining option for me is to embark on the AlarmManager class, but this is essentially recreating the alarmclock class and I want this application be generic (it can apply to most alarm clock applications) and not have to rely on its own.

Any assistance would be very appreciated.

Upvotes: 0

Views: 1318

Answers (2)

Code Droid
Code Droid

Reputation: 10472

What you need to do is use AlarmManager to broadcast out a pulse. This is the MOST RELIABLE way to get a pulse to go out. Have a broadcast receiver listen on that pulse an pass over to a service or start an Activity as needed. There you will examine your list of Alarm conditions and see if they have been met. Note you can also check timestamp at this point. Yes AlarmManager is far more reliable than any other service you can use for this.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007339

There must be a way to do this, simply by utilizing some feature of the native Android alarmclock class.

You are welcome to your opinion, though your opinion may need to be accompanied by your own fork of Android and your own line of mobile devices.

First, there isn't really much of a "native Android alarmclock class". It is mostly just an Intent action string and a series of keys for extras. The implementation of the alarm clock functionality is device- and user-dependent, though many will simply use one from the Android open source project.

At this point, you run into two problems:

  1. The app from the Android open source project does not support what you want

  2. No other app has to support what you want, as it is outside the scope of documented behavior

Upvotes: 1

Related Questions