Note that there are some explanatory texts on larger screens.

plurals
  1. POCalendar Edit Event Force Close Issue
    primarykey
    data
    text
    <p>I am trying to add calendar events in the background without using Intents. Event gets saved successfully. However when i try to edit that event manually i get Force Close error.</p> <pre><code>int cal_id = getCalendar_ID(); if(cal_id != 0){ saveCalendarEvent(cal_id); } private void saveCalendarEvent(int calid){ try{ Calendar cal = Calendar.getInstance(); ContentValues event = new ContentValues(); long startTime = cal.getTimeInMillis() + 1000 * 60 * 60; long endTime = cal.getTimeInMillis() + 1000 * 60 * 60 * 2; event.put("calendar_id", calid); event.put("title", "Event Title"); event.put("description", "Event Desc"); event.put("eventLocation", "Event Location"); event.put("dtstart", startTime); event.put("dtend", endTime); event.put("allDay", 0); Uri newEvent = getContentResolver().insert(Uri.parse("content://com.android.calendar/events"), event); if (newEvent != null) { long id = Long.parseLong( newEvent.getLastPathSegment() ); ContentValues values = new ContentValues(); values.put( "event_id", id ); values.put( "method", 1 ); values.put( "minutes", 15 ); // 15 minuti getContentResolver().insert( Uri.parse( "content://com.android.calendar/reminders" ), values ); } }catch(Exception ee){} } private int getCalendar_ID() { int calendar_id = 0; String[] projection = new String[] { "_id", "name" }; String selection = "selected=1"; String path = "calendars"; Cursor calendarCursor = getCalendarCursor(projection, selection, path); if (calendarCursor != null &amp;&amp; calendarCursor.moveToFirst()) { int nameColumn = calendarCursor.getColumnIndex("name"); int idColumn = calendarCursor.getColumnIndex("_id"); do { String calName = calendarCursor.getString(nameColumn); String calId = calendarCursor.getString(idColumn); if (calName != null /*&amp;&amp; calName.contains("Test")*/) { calendar_id = Integer.parseInt(calId); } } while (calendarCursor.moveToNext()); } return calendar_id; } private Cursor getCalendarCursor(String[] projection, String selection, String path) { Uri calendars = Uri.parse("content://calendar/" + path); Cursor cCursor = null; try { cCursor = managedQuery(calendars, projection, selection, null, null); } catch (IllegalArgumentException e) {} if (cCursor == null) { calendars = Uri.parse("content://com.android.calendar/" + path); try { cCursor = managedQuery(calendars, projection, selection, null, null); } catch (IllegalArgumentException e) {} } return cCursor; } </code></pre> <p><strong>Force Close Error log</strong></p> <pre><code>11-23 12:22:39.572: E/AndroidRuntime(2630): Caused by: java.lang.NullPointerException 11-23 12:22:39.572: E/AndroidRuntime(2630): at java.util.TimeZone.getTimeZone(TimeZone.java:286) 11-23 12:22:39.572: E/AndroidRuntime(2630): at com.android.calendar.TimezoneAdapter.showInitialTimezones(TimezoneAdapter.java:255) 11-23 12:22:39.572: E/AndroidRuntime(2630): at com.android.calendar.TimezoneAdapter.&lt;init&gt;(TimezoneAdapter.java:198) 11-23 12:22:39.572: E/AndroidRuntime(2630): at com.android.calendar.EditEvent.onCreate(EditEvent.java:707) 11-23 12:22:39.572: E/AndroidRuntime(2630): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 11-23 12:22:39.572: E/AndroidRuntime(2630): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1612) 11-23 12:22:39.572: E/AndroidRuntime(2630): ... 11 more </code></pre> <p>Using 2.3.7 device. Appreciate any help. thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload