ContentProvider URL Calendar on Sense Android Phones

I have an application that adds an event to the calendar on the device. I have the following URLs for Calendar ContentProvider:

Pre Froyo: content://calendar/calendars
Froyo: content://com.android.calendar/calendars

These URLs work fine for Nexus One, but don't return calendars to HTC Desire / Incredible / Hero. Probably all phones with a Sense user interface. This happens in 2.1 and 2.2.

Has anyone encountered this problem before and have any workarounds?

+3
source share
1 answer

use this code to get the URI for your platform.

private String getCalendarUriBase() {

            String calendarUriBase = null;
            Uri calendars = Uri.parse("content://calendar/calendars");
            Cursor managedCursor = null;
            try {
                managedCursor = managedQuery(calendars, null, null, null, null);
            } catch (Exception e) {
            }
            if (managedCursor != null) {
                calendarUriBase = "content://calendar/";
            } else {
                calendars = Uri.parse("content://com.android.calendar/calendars");
                try {
                    managedCursor = managedQuery(calendars, null, null, null, null);
                } catch (Exception e) {
                }
                if (managedCursor != null) {
                    calendarUriBase = "content://com.android.calendar/";
                }
            }
            return calendarUriBase;
        }
+3
source

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


All Articles