这是我的代码:
public class CalendarReminderReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equalsIgnoreCase(CalendarContract.ACTION_EVENT_REMINDER)) {
//Do Something Here to get EVENT ID
}
}
}
无论如何从广播接收器获取提醒事件的事件ID? 这是我的清单:
<receiver
android:name="com.calendar.CalendarReminderReceiver">
<intent-filter>
<action android:name="android.intent.action.EVENT_REMINDER" />
<data android:scheme="content"/>
</intent-filter>
</receiver>
答案 0 :(得分:6)
也许为时已晚,但这是我的解决方案:
if (intent.getAction().equalsIgnoreCase(CalendarContract.ACTION_EVENT_REMINDER)) {
//Do Something Here to get EVENT ID
Uri uri = intent.getData();
String alertTime = uri.getLastPathSegment();
String selection = CalendarContract.CalendarAlerts.ALARM_TIME + "=?";
Cursor cursor = context.getContentResolver().query(CalendarContract.CalendarAlerts.CONTENT_URI_BY_INSTANCE, new String[]{CalendarContract.CalendarAlerts.EVENT_ID},selection,new String[]{alertTime}, null);
}