2

您好开发了一个具有一些功能的 android 应用程序,可以在日历应用程序中添加我们的事件详细信息。我的应用程序运行良好。但有时它会强制关闭并在调试时在 logcat 中显示错误。我为新旧版本的 android OS 使用了 2 个内容 uri。

那些是

 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)
4

2 回答 2

9

尝试添加它也可能会起作用。

    eventValues.put("eventTimezone", TimeZone.getDefault().getID());
于 2014-08-21T19:12:19.340 回答
-1

尝试这个:

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());       
于 2014-03-22T09:13:34.803 回答