我有一个将事件添加到设备上日历的应用程序.日历ContentProvider具有以下URL:
Pre Froyo: content://calendar/calendars
Froyo: content://com.android.calendar/calendars
这些网址适用于Nexus One,但不会在HTC Desire / Incredible / Hero上返回任何日历.可能所有带有Sense UI的手机.这发生在2.1和2.2.
有人遇到过这个问题吗,并且有任何解决方法?
最佳答案
使用此代码获取您平台的URI
原文链接:https://www.f2er.com/android/531585.htmlprivate String getCalendarUriBase() {
String calendarUriBase = null;
Uri calendars = Uri.parse("content://calendar/calendars");
Cursor managedCursor = null;
try {
managedCursor = managedQuery(calendars,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);
} catch (Exception e) {
}
if (managedCursor != null) {
calendarUriBase = "content://com.android.calendar/";
}
}
return calendarUriBase;
}