How to set android reminder/alarm?

2019-08-28 16:06发布

问题:

I have got some times stored in ISO format. Some of these times are flagged to either 1(on) or 0(off) set in another column. I need to set a reminder at the times flagged to 1, but how would I pass that each date to the reminder class?

回答1:

There is no public API for the Alarm Clock application.

There is no public API for the Calendar application, though since it is a native UI for a Google Calendar, you could push an event over to the Google Calendar via its GData API.



回答2:

ContentValues reminderContentValues = new ContentValues();
reminderContentValues.put(FIELD_REMINDER_EVENT_ID, eventId);    
reminderContentValues.put(FIELD_REMINDER_METHOD, 1);    
reminderContentValues.put(FIELD_REMINDER_MIN, minutesBefore);   
mContext.getContentResolver().insert(getRemindersUri(), reminderContentValues);