2012-01-18 4 views
10

コンテンツプロバイダを使用しようとしましたが、イベントがカレンダーに追加されませんでした。アクティビティからGoogleカレンダーに予定を追加するには?

final ContentResolver cr = ctx.getContentResolver(); 

ContentValues cv = new ContentValues();  
cv.put("calendar_id", l_calId);  
cv.put("title", title);  
cv.put("description", description);  
cv.put("dtstart", millis1);  
cv.put("hasAlarm", 1); 
cv.put("dtend", millis2);  
cv.put("eventLocation", "Hall: "+location);  
cv.put("transparency", 1);  
cv.put("hasAlarm", 1);  


Uri newEvent ;  
if (Integer.parseInt(Build.VERSION.SDK) == 8)  
    newEvent = cr.insert(Uri.parse("content://com.android.calendar/events"), cv);  
else  
    newEvent = cr.insert(Uri.parse("content://com.android.calendar/events"), cv); 

答えて

7

あなたのユーザーのカレンダーにイベントを追加したいと仮定すると、アンドロイド2.xの上でそれをやっての(サポートされていない)方法はhereに記載されています。

Android 4.0以降、サポートされていない方法でサポートを中断している間に、練習が変更されました(here)。これは、ICSを担当する公式のAPIに置き換えられました。これは、hereと記載されています。

関連する問題