Creating syncable Calendar in ICS
- by user1390816
I have a problem with creating a new Calendar in ICS. The Calendar should be synyable to the google Calendar. I try following:
Uri calendarUri = CalendarContract.Calendars.CONTENT_URI;
calendar.put(CalendarContract.Calendars.ACCOUNT_NAME, sync_account);
calendar.put(CalendarContract.Calendars.ACCOUNT_TYPE, "com.google");
calendar.put(CalendarContract.Calendars.NAME, name);
calendar.put(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, displayName);
calendar.put(CalendarContract.Calendars.CALENDAR_COLOR, 0xFF008080);
calendar.put(CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL, CalendarContract.Calendars.CAL_ACCESS_OWNER);
calendar.put(CalendarContract.Calendars.OWNER_ACCOUNT, true);
calendar.put(CalendarContract.Calendars.VISIBLE, 1);
calendar.put(CalendarContract.Calendars.SYNC_EVENTS, 1);
calendarUri = calendarUri.buildUpon()
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_NAME, sync_account)
.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_TYPE, "com.google") // CalendarContract.ACCOUNT_TYPE_LOCAL
.build();
Uri result = activity.getContentResolver().insert(calendarUri, calendar);
an I get always this error:
09-17 17:11:30.278: E/AndroidRuntime(13243): FATAL EXCEPTION: CalendarSyncAdapterAccountMonitor
09-17 17:11:30.278: E/AndroidRuntime(13243): java.lang.IllegalArgumentException: the name must not be empty: null
09-17 17:11:30.278: E/AndroidRuntime(13243): at android.accounts.Account.<init>(Account.java:48)
09-17 17:11:30.278: E/AndroidRuntime(13243): at com.google.android.syncadapters.calendar.CalendarSyncAdapter.onAccountsUpdated(CalendarSyncAdapter.java:1129)
09-17 17:11:30.278: E/AndroidRuntime(13243): at android.accounts.AccountManager$11.run(AccountManager.java:1279)
09-17 17:11:30.278: E/AndroidRuntime(13243): at android.os.Handler.handleCallback(Handler.java:605)
09-17 17:11:30.278: E/AndroidRuntime(13243): at android.os.Handler.dispatchMessage(Handler.java:92)
09-17 17:11:30.278: E/AndroidRuntime(13243): at android.os.Looper.loop(Looper.java:137)
09-17 17:11:30.278: E/AndroidRuntime(13243): at android.os.HandlerThread.run(HandlerThread.java:60)
09-17 17:11:30.293: E/android.os.Debug(1989): !@Dumpstate > dumpstate -k -t -n -z -d -o /data/log/dumpstate_app_error
What can I do with the CalendarSyncAdapterAccountMonitor, that it is not empty?
Thanks in advance.