在三星Galaxy设备上插入日历的错误

时间:2015-02-23 21:33:04

标签: android samsung-mobile android-calendar android-account calendarcontract

我有一个只在三星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);

StackTrace:

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)

我如何解决这个错误?

0 个答案:

没有答案