0

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:

  • Android developer documents;

  • Pretty much every forum post on SO about this topic;

  • Utilizing various other intents i found by searching through the deskclock source code;

  • Importing the Alarms class, the setAlarm class.

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.

Community
  • 1
  • 1
Squagem
  • 724
  • 4
  • 17
  • 1
    You have the assistance, where is the appreciation? – Code Droid Jul 30 '12 at 18:10
  • Please see my reply below! Considering there are two replies I need to confirm the working functionality of your potential solution before choosing a correct answer. – Squagem Jul 30 '12 at 18:21
  • @Squagem you mean you want to update existing alarms? – likejudo Mar 05 '14 at 00:40
  • I wanted to be able to update alarms that I activated through the `ACTION_SET_ALARM` intent, instead of creating a new alarm every time I want to change the time set for that alarm. – Squagem Mar 10 '14 at 01:33

2 Answers2

1

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

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I see, so to summarize, you mean to say that there is in fact no way to do this using the android open source (deskclock) alarm clock. Instead, I need to test for each for installed applications and work from there in determining if they offer the functionality of setting unique alarms. Thank you for your reply! – Squagem Jul 30 '12 at 18:03
  • Squagem, there are ways to do it as I have shown but the AlarmClock is a piece of .... – Code Droid Jul 30 '12 at 18:06
  • @CodeDroid, using the AlarmManager seems to be a viable solution, but does this address the issue of using the android open source DeskClock? I can't seem to see how I will be able to modify the currently-existing alarm clocks using an external alarm manager. – Squagem Jul 30 '12 at 18:15
  • Well as I see it you cannot solve it using DeskClock unless you rewrite. So CommonsWare answer for the given question is correct. However its not that complicated to implement your own, and part of how to do that might be an AlarmManager perhaps in combination with your version of an open source Clock. – Code Droid Jul 30 '12 at 20:45
  • @CommonsWare how would one "use the android opensource (deskclock) project" - bundle the code in one's app? – likejudo Mar 05 '14 at 00:38
  • @likejiujitsu: Um, I guess so. – CommonsWare Mar 05 '14 at 00:46
  • @CommonsWare The apache 2.0 license seems fine so I downloaded and imported the code into an Eclipse project. Unfortunately it doesn't compile - lots of errors about unrecognized classes. http://stackoverflow.com/questions/22182939/where-is-alarm-clock-functionality-in-android – likejudo Mar 05 '14 at 01:15
0

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.

Code Droid
  • 10,344
  • 17
  • 72
  • 112
  • using the AlarmManager seems to be a viable solution, but does this address the issue of using the android open source DeskClock? I can't seem to see how I will be able to modify the currently-existing alarm clocks using an external alarm manager. – Squagem Jul 30 '12 at 18:25