您开发了一个具有一些功能的Android应用程序,可以在Calendar应用程序中添加我们的事件详细信息。我的应用程序运行正常。但有时它会在调试时强制关闭并在logcat中显示错误。我使用了2个内容uri用于新旧版本的Android操作系统。
那些
if(){
Uri calendars = Uri.parse("content://calendar/calendars");
}
else{
calendars = Uri.parse("content://com.android.calendar/calendars");
}
我正在努力解决我的问题,但没有取得成功。请为我提供此问题的最佳解决方案。我在下面添加了我的logcat。
提前致谢。
java.lang.IllegalArgumentException: Event values must include an eventTimezone
03-02 18:28:35.836: E/AndroidRuntime(1362): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
03-02 18:28:35.836: E/AndroidRuntime(1362): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
03-02 18:28:35.836: E/AndroidRuntime(1362): at android.content.ContentProviderProxy.insert(ContentProviderNative.java:415)
03-02 18:28:35.836: E/AndroidRuntime(1362): at android.content.ContentResolver.insert(ContentResolver.java:730)
03-02 18:28:35.836: E/AndroidRuntime(1362): at in.plackal.lovecyclesfree.CycleManager.setAlertOnDevice(CycleManager.java:1083)
03-02 18:28:35.836: E/AndroidRuntime(1362): at in.plackal.lovecyclesfree.ActivityManager.onPause(ActivityManager.java:83)
03-02 18:28:35.836: E/AndroidRuntime(1362): at android.app.Activity.performPause(Activity.java:4563)
03-02 18:28:35.836: E/AndroidRuntime(1362): at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1195)
03-02 18:28:35.836: E/AndroidRuntime(1362): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2693)
答案 0 :(得分:8)
尝试添加它也可能会起作用。
eventValues.put("eventTimezone", TimeZone.getDefault().getID());
答案 1 :(得分:0)
试试这个:
Calendar cal = Calendar.getInstance();
long l = cal.getTimeInMillis();
long cal_Id = 1;
ContentResolver CR = getContentResolver();
ContentValues calEvent = new ContentValues();
calEvent.put(CalendarContract.Events.CALENDAR_ID, cal_Id); // XXX pick)
calEvent.put(CalendarContract.Events.TITLE, " Demo Data");
calEvent.put(CalendarContract.Events.DTSTART,l);
calEvent.put(CalendarContract.Events.DTEND, l+60 * 1000);
calEvent.put(CalendarContract.Events.EVENT_TIMEZONE, "Indian/Christmas"); // Here choose your location time zone
ContentResolver C2 = getContentResolver();
Uri uri = C2.insert(URL, calEvent);
int id = Integer.parseInt(uri.getLastPathSegment());