When the calendar activated the reminder receiver in Android, how can I get the event ID?

Here is my code:

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
    }

}

}

Is there anyway to get the event identifier from the broadcast receiver for reminder events? Here is my manifest:

<receiver
        android:name="com.calendar.CalendarReminderReceiver">
        <intent-filter>
            <action android:name="android.intent.action.EVENT_REMINDER" />
            <data android:scheme="content"/>
        </intent-filter>
</receiver>
+4
source share
1 answer

Perhaps too late, but here is my solution:

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);

}
+4
source

Source: https://habr.com/ru/post/1523973/


All Articles