2

Hi developed an android application with some functionality to add our events details in Calendar application.My application is working fine. But some times it is giving force close and displaying an error in logcat while debugging. I used 2 content uri's for old and new version of android OS.

those are

 if(){
    Uri calendars = Uri.parse("content://calendar/calendars");
    }
    else{
    calendars = Uri.parse("content://com.android.calendar/calendars");
    }

I am trying to resolve my problem but did not get success. Please provide me a best solution for this issue. I added my logcat below.

Thanks in advance.

   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)
Raghu Mudem
  • 6,793
  • 13
  • 48
  • 69
  • See http://stackoverflow.com/q/9533757/1321873 – Rajesh Jun 25 '12 at 13:00
  • Thank you for your response. I saw that in previous but did not get help. – Raghu Mudem Jun 25 '12 at 13:36
  • You can find some information about your problem in this urls: - [How to add calendar events in Android?](http://stackoverflow.com/questions/3721963/how-to-add-calendar-events-in-android) - [[Android]Google Calendar API change for ICS](http://bluegray-javalearning.blogspot.com.es/2012/05/androidgoogle-calendar-api-change-for.html) If you use Google API's >= 14 you need use both. – MAJS Oct 17 '12 at 14:37

2 Answers2

9

Try to add this also may be it will work.

    eventValues.put("eventTimezone", TimeZone.getDefault().getID());
TaRan LaYal
  • 148
  • 1
  • 9
-1

try this:

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());       
Chirag Parmar
  • 1,064
  • 2
  • 13
  • 29