我有一个只发生在三星 Galaxy Tab、三星 Galaxy Win Duos 和三星 Galaxy S Duos 中的错误。
我正在尝试将链接的日历插入应用程序帐户:
Uri calUri = CalendarContract.Calendars.CONTENT_URI;
ContentValues cv = new ContentValues();
cv.put(CalendarContract.Calendars.ACCOUNT_NAME, account.name);
cv.put(CalendarContract.Calendars.ACCOUNT_TYPE, account.type);
cv.put(CalendarContract.Calendars.NAME, context.getString(R.string.app_name));
cv.put(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, context.getString(R.string.app_name));
cv.put(CalendarContract.Calendars.CALENDAR_COLOR, R.color.application_color);
cv.put(CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL, CalendarContract.Calendars.CAL_ACCESS_READ);
cv.put(CalendarContract.Calendars.OWNER_ACCOUNT, true);
cv.put(CalendarContract.Calendars.VISIBLE, 1);
cv.put(CalendarContract.Calendars.SYNC_EVENTS, 1);
cv.put(CalendarContract.Calendars.CALENDAR_TIME_ZONE, GregorianCalendar.getInstance().getTimeZone().getID());
calUri = calUri.buildUpon()
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_NAME, account.name)
.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_TYPE, account.type)
.build();
Uri result = context.getContentResolver().insert(calUri, cv);
但是这一行中的这个生成错误:
Uri result = context.getContentResolver().insert(calUri, cv);
堆栈跟踪:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.packpage.example/application.MainActivity}: java.lang.IllegalArgumentException: Unknown URL content://com.android.calendar/calendars?caller_is_syncadapter=true&account_name=Fulano%20Cicrano&account_type=com.packpage.example
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2114)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.IllegalArgumentException: Unknown URL content://com.android.calendar/calendars?caller_is_syncadapter=true&account_name=Fulano%20Cicrano&account_type=com.packpage.example
at android.content.ContentResolver.insert(ContentResolver.java:862)
at application.component.calendar.CalendarOperation.addCalendar(CalendarOperation.java:191)
at application.component.calendar.CalendarOperation.createCalendar(CalendarOperation.java:31)
at application.controllers.MainActivity.onStart(MainActivity.java:548)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1178)
at android.app.Activity.performStart(Activity.java:5213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2087)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(NativeStart.java)
我该如何解决这个错误?