2012-10-25 14 views
6

好吧,我非常精確地在這裏閱讀文檔:http://developer.android.com/guide/topics/providers/calendar-provider.html#update-event和書面的東西是這樣的:意圖修改日曆事件不起作用

// Here is an example of an intent that sets a new title for a specified event and lets users edit the event in the Calendar. 

long eventID = 208; 
Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventID); 
Intent intent = new Intent(Intent.ACTION_EDIT) 
    .setData(uri) 
    .putExtra(Events.TITLE, "My New Title"); 
startActivity(intent); 

對我來說,這是行不通的 - 它打開正確的事件,但不可能編輯它 - 所有字段都是隻讀的。只有我可以改變的領域是時區和提醒。其他所有內容都是隻讀的。難道我做錯了什麼?

我的API級別爲14(ICS)

+0

您的API級別設置爲&您是否使用Google API? – jnthnjns

+0

我的手機API級別爲14(也是我的應用程序編碼爲14級)&我不明白您的問題的第二部分... – qkx

+0

當您爲項目選擇API級別時,您會看到每個級別的兩個級別。 * Android 4.0 API 14 * && * Google API's API 14 * – jnthnjns

回答

6

所以我不認爲你做錯了什麼 - 我放在一起的同樣的事情,基本實現通過命令行和限制同樣適用:

am start -a android.intent.action.EDIT --es title "New Title" content://com.android.calendar/events/1 

我只能編輯相同的字段 - 你可能會更好的做一個ACTION_VIEW並讓用戶決定編輯(對不起,我沒有更好的答案給你,這有點煩人)

+0

完全相同的我......但爲什麼文檔說別的?或者他們忘了提及一些非常重要的東西(如很多次之前):) – qkx

+4

請爲此錯誤投票:http://code.google.com/p/android/issues/detail?id=39402 –

+0

好的,我投了票...;) – qkx

3

解決方法此problem:如果您使用Intent.ACTION_VIEW,您至少會得到一個可以點擊編輯按鈕的活動,之後您可以編輯標題和位置以及其他所有內容(無論如何都是在默認日曆應用程序中)。