[英]Android Calendar
我正在嘗試將項目放入日歷中,但不知道如何對其進行編碼。 這是我到目前為止所擁有的,但它將它插入到主日歷中。
String calName;
String calId = null;
String[] projection = new String[] { "_id", "name" };
Uri calendars = Uri.parse("content://calendar/calendars");
Cursor managedCursor = managedQuery(calendars, projection, null, null, null);
ContentValues event = new ContentValues();
event.put("calendar_id", calId);
event.put("title", strTitle);
event.put("description", strDescription);
event.put("eventLocation", strLocation);
event.put("dtstart", StartTime);
event.put("dtend", EndTime);
Uri eventsUri = Uri.parse("content://calendar/events");
Uri calUri = getContentResolver().insert(eventsUri, event);
所以我的問題是:
如何創建自己的日歷以將事件放入
如何將我的事件插入該日歷(使用上面的代碼或新代碼)
如何檢查事件是否已存在
~~~更新:~~~
我要做的是我的用戶將輸入標題和日期,我的應用程序將采用該標題和日期,將它們放入數據庫(到目前為止我所做的一切),現在我想采用標題和日期並將它們放入專門用於我的應用程序事件的特殊日歷中。 我需要做的第一件事是讓應用程序創建一個新日歷。 比將事件插入到下面的代碼幫助我做的那個日歷中。 還在玩它。 比我想重新運行我的應用程序並檢查事件是否存在。 就這樣。
首先,自 2.2 以來內容解析器發生了變化,我認為從content://calendar/calendars
到content://com.android.calendar/calendars
。
要插入事件,檢索事件檢查此代碼
您將找到所需的一切以及如何處理跨平台的內容解析器更改。
要更新 Google 日歷,請使用Google 日歷 GData API 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.