1
我試圖直接使用此代碼添加事件:直接添加事件到日曆
// Construct event details
long startMillis = 0;
long endMillis = 0;
Calendar beginTime = Calendar.getInstance();
beginTime.set(2013, 3, 14, 7, 30);
startMillis = beginTime.getTimeInMillis();
Calendar endTime = Calendar.getInstance();
endTime.set(2013, 3, 14, 8, 45);
endMillis = endTime.getTimeInMillis();
// Insert Event
ContentResolver cr = getContentResolver();
ContentValues values = new ContentValues();
values.put(CalendarContract.Events.DTSTART, startMillis);
values.put(CalendarContract.Events.DTEND, endMillis);
values.put(CalendarContract.Events.TITLE, "Walk The Dog");
values.put(CalendarContract.Events.DESCRIPTION, "My dog is bored, so we're going on a really long walk!");
values.put(CalendarContract.Events.CALENDAR_ID, 3);
values.put("eventTimezone", "Europe/London");
Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI, values);
// Retrieve ID for new event
String eventID = uri.getLastPathSegment();
此代碼語法是正確的,但不向日曆添加事件。 問題是什麼? 而且Eclipse說
String eventID = uri.getLastPathSegment();
未被使用。
對不起,我已經 <使用許可權的android:NAME = 「android.permission.READ_CALENDAR」/> <使用許可權的android:NAME = 「android.permission.WRITE_CALENDAR」/> – 2013-03-05 20:47:36
我忘了說,我也有一個錯誤: 錯誤打開跟蹤文件:沒有這樣的文件或目錄(2) – 2013-03-05 20:51:11