10

Is it by any chance possible to get a list of alarms saved in the alarm application of android ? I am making an application which just needs to show the alarms set in the Alarm application.

Thanx

Alex.F
  • 3,652
  • 1
  • 27
  • 47
JaVadid
  • 6,937
  • 13
  • 40
  • 54
  • 1
    AFAIK know there are a lot of Clock Alarm applications out there, all probably use their own set of data. – Pentium10 Jun 30 '10 at 08:01

3 Answers3

14

There is a good explanation on this post regarding this. There are no guarantees that the AlarmClock app will be on every device your app is installed on. For example, many of the HTC phones replace it with HTC's own "World Clock" app.

However, assuming the stock AlarmClock app is present, you should be able to get a cursor from its content provider. See this project as an example.

Community
  • 1
  • 1
seanhodges
  • 16,593
  • 14
  • 67
  • 89
  • 5
    The content provider for the stock AlarmClock app is not part of the Android SDK. The provider may change without warning in future versions of Android. The identity of the stock AlarmClock app itself might change in future versions of Android. – CommonsWare Jun 30 '10 at 09:04
  • thanx buddy... ya i have already referred the post u mentioned and m taking into consideration that android alarm clock will b present... But the project is ultra cool... it has most of the things i need... will check it and respond in due time... Thanx again dude.. – JaVadid Jun 30 '10 at 09:12
  • @CommonsWare Thanx for the info Mark, i guess i u are right but some clients don listen. I m thinking of dropping the idea but had to research a bit to humor them. Thanx again... – JaVadid Jun 30 '10 at 09:14
  • 4
    The interfaces exposed by the AlarmClock app may change, as stated by @CommonsWare, but this is no different from any other Android app that exposes a set of intents or content providers. You will need to handle the exceptions gracefully, but careful design (and lots of testing) should provide a fairly stable implementation. – seanhodges Jun 30 '10 at 14:10
8
final String tag_alarm = "tag_alarm";
Uri uri = Uri.parse("content://com.android.alarmclock/alarm");
Cursor c = getContentResolver().query(uri, null, null, null, null);
Log.i(tag_alarm, "no of records are " + c.getCount());
Log.i(tag_alarm, "no of columns are " + c.getColumnCount());
if (c != null) {
    String names[] = c.getColumnNames();
    for (String temp : names) {
        System.out.println(temp);
    }
    if (c.moveToFirst()) {
        do {
            for (int j = 0; j < c.getColumnCount(); j++) {
                Log.i(tag_alarm, c.getColumnName(j)
                        + " which has value " + c.getString(j));
            }
        } while (c.moveToNext());
    }
}

Use this code...and you will get all the details. Enjoy!

jrajav
  • 5,208
  • 1
  • 21
  • 32
  • 2
    This is actually a good answer and should be accepted. Those registrys hold the alarm values, it's just that they need to be treated as int dates depending on what you do with them. True also that the alarm clock app may not be present – quinestor Oct 26 '12 at 17:10
3

For debugging purposes, you can use "adb shell dumpsys alarm" from the console.

blacharnia
  • 2,104
  • 2
  • 15
  • 16