我正在以编程方式创建日历,并且所有内容都设置得很好但是日历的名称。这是我正在使用的方法。
private Uri createCalendar(String email){
Uri target = Uri.parse(CalendarContract.Calendars.CONTENT_URI.toString());
target = target.buildUpon().appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_NAME, email)
.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_TYPE, "com.google").build();
ContentValues values = new ContentValues();
values.put(CalendarContract.Calendars.ACCOUNT_NAME, email);
values.put(CalendarContract.Calendars.ACCOUNT_TYPE, "com.google");
values.put(CalendarContract.Calendars.NAME, context.getResources().getString(R.string.app_name));
values.put(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, context.getResources().getString(R.string.app_name));
values.put(CalendarContract.Calendars.CALENDAR_COLOR, Util.getColor(context, R.color.primary));
values.put(CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL, CalendarContract.Calendars.CAL_ACCESS_ROOT);
values.put(CalendarContract.Calendars.OWNER_ACCOUNT, email);
values.put(CalendarContract.Calendars.VISIBLE, 1);
values.put(CalendarContract.Calendars.SYNC_EVENTS, 1);
values.put(CalendarContract.Calendars.CALENDAR_TIME_ZONE, TimeZone.getDefault().getID());
values.put(CalendarContract.Calendars.CAN_PARTIALLY_UPDATE, 1);
values.put(CalendarContract.Calendars.CAL_SYNC1, "https://www.google.com/calendar/feeds/" + email + "/private/full");
values.put(CalendarContract.Calendars.CAL_SYNC2, "https://www.google.com/calendar/feeds/default/allcalendars/full/" + email);
values.put(CalendarContract.Calendars.CAL_SYNC3, "https://www.google.com/calendar/feeds/default/allcalendars/full/" + email);
values.put(CalendarContract.Calendars.CAL_SYNC4, 1);
values.put(CalendarContract.Calendars.CAL_SYNC5, 0);
values.put(CalendarContract.Calendars.CAL_SYNC8, System.currentTimeMillis());
Uri newCalendar = context.getContentResolver().insert(target, values);
return newCalendar;
}
如上所述,一切正常,颜色,所有者帐户等等,但是在创建日历时,它的名称始终是“事件”。我试图手动输入名称(不使用getStrings()
),但也没有用。
关于可能发生的事情的任何想法?