Reflection - Trying to convert some java code

kanaida

Active Member
Licensed User
Longtime User
Hey guys can anyone help me translate this to using the reflection library?

B4X:
Uri uri = Uri.parse("content://com.android.alarmclock/alarm")

Cursor c = getContentResolver().query(uri, null, null, null, null);
    Log.i(tag_alram, "no of records are" + c.getCount());
    Log.i(tag_alram, "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 {
                int i = 0;
                // Log.i(tag_alram,
                // c.getString(c.getColumnIndex(names[i])));
                for (int j = 0; j < c.getColumnCount(); j++) {
                    Log.i(tag_alram, c.getColumnName(j)
                            + " which has value " + c.getString(j));
                }
            } while (c.moveToNext());
        }

It gets the current list of alarms that all apps set in android. There's examples on how to set an alarm yourself with StartServiceAt() but I was curious what other alarms other apps have set up on my phone, but are not visible anywhere.
 

lagore

Active Member
Licensed User
Longtime User
Not sure about using the Reflection library but is should be easy to write a mini library to access the features as it is the same structure as the calendar/contacts librarys. can look at it later today.
 
Upvote 0

kanaida

Active Member
Licensed User
Longtime User
Not sure about using the Reflection library but is should be easy to write a mini library to access the features as it is the same structure as the calendar/contacts librarys. can look at it later today.

Thanks. Even better if I can also get the name of the package that created them eg. com.android.settings or whatever it might be. Not sure if that's possible but would be very useful info.
 
Upvote 0

lagore

Active Member
Licensed User
Longtime User
Hi not sure if this is what you are looking for and if it makes any sense, I had to modify as the content provider "content://com.android.alarmclock/alarm" is not a standard it can be modified by the manufacturer I had to use "content://com.htc.android.alarmclock/alarm" for it to work on my phone. the output was;
no of records are3
no of columns are10

_id which has value 1
hour which has value 23
minutes which has value 40
daysofweek which has value 127
alarmtime which has value 1332474000000
enabled which has value 0
vibrate which has value 1
message which has value
alert which has value content://media/internal/audio/media/74
snoozed which has value 0

_id which has value 2
hour which has value 1
minutes which has value 0
daysofweek which has value 127
alarmtime which has value 1331103600000
enabled which has value 0
vibrate which has value 1
message which has value
alert which has value content://media/internal/audio/media/74
snoozed which has value 0

_id which has value 3
hour which has value 19
minutes which has value 15
daysofweek which has value 31
alarmtime which has value 1327518900000
enabled which has value 0
vibrate which has value 1
message which has value
alert which has value content://media/internal/audio/media/74
snoozed which has value 0
 
Upvote 0
Top