2

Using AlarmManager I can set alarm for any time from the android App. But is there any way to list all the alarms set by me. What should be my approach towards that, as AlarmManager do not provide with such methods. Should I go for saving the alarm as a file in the memory.?

Please Help me with this.

Veer Shrivastav
  • 5,434
  • 11
  • 53
  • 83

2 Answers2

2

A. 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.

B. You have to create a layout for items of the ListView.

You can find tutorials about this on Internet : http://www.vogella.com/articles/AndroidListView/article.html http://codehenge.net/blog/2011/05/customizing-android-listview-item-layout/

c.

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());
    }
}
Community
  • 1
  • 1
Tarun Gupta
  • 1,232
  • 2
  • 13
  • 26
2

Visiting all the possible links I came to a solution that creating an app that would retrieve the alarms set on the OS level is not possible. Ya.. to some extent it would be possible but in many cases it would be machine dependent.

So better option is to save your Alarms in your database.

Veer Shrivastav
  • 5,434
  • 11
  • 53
  • 83