0

我们正在从我们的代码中将条目添加到 Android 日历中。由于某种原因,日历似乎已以某种方式损坏。

我们根本无法删除任何事件——即使是那些没有从我们的代码中添加的事件。如果我们尝试删除通过我们的代码添加的一个,它会崩溃。

这是我们用来插入事件的代码。请注意,文本是希伯来语,我们谈论的是 Android 4.1 及更高版本。

        // Select which calendar application to use:
    int cal_id = CalendarAppointmentScheduler._calIds[0];

    // Use a ContentValues object to hold the details of the calendar event you wish to set:
    ContentValues cv = new ContentValues();
    cv.put(Events.CALENDAR_ID, cal_id);
    cv.put(Events.TITLE, ctx.getString(R.string.add_appointment_to_calendar_title) + " " + ad.doctorName + " (" +
        ad.doctorSpecialty + ")");
    cv.put(Events.EVENT_LOCATION, ad.address);
    cv.put(Events.DTSTART, startTime);
    cv.put(Events.DTEND, endTime);
    cv.put(Events.ALL_DAY, 0);  // true = 1, false = 0
    cv.put(Events._ID, ad.diaryRecordIndex);
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
        cv.put(Events.EVENT_TIMEZONE, TimeZone.getDefault().getID());

这是我们得到的 logcat:

11-04 16:22:25.975: E/AndroidRuntime(25027): FATAL EXCEPTION: main
11-04 16:22:25.975: E/AndroidRuntime(25027): java.lang.NumberFormatException: Invalid int: "350511201315411-04 16:22:25.975: E/AndroidRuntime(25027): FATAL EXCEPTION: main
11-04 16:22:25.975: E/AndroidRuntime(25027): java.lang.NumberFormatException: Invalid int: "350511201315451602"
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.Integer.invalidInt(Integer.java:138)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.Integer.parse(Integer.java:378)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.Integer.parseInt(Integer.java:366)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.Integer.parseInt(Integer.java:332)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at android.database.MatrixCursor.getInt(MatrixCursor.java:247)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.calendar.EventInfoFragment.initEventCursor(EventInfoFragment.java:1062)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.calendar.EventInfoFragment.access$700(EventInfoFragment.java:117)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.calendar.EventInfoFragment$QueryHandler.onQueryComplete(EventInfoFragment.java:469)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.calendar.AsyncQueryService.handleMessage(AsyncQueryService.java:412)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at android.os.Handler.dispatchMessage(Handler.java:99)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at android.os.Looper.loop(Looper.java:137)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at android.app.ActivityThread.main(ActivityThread.java:5103)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.reflect.Method.invokeNative(Native Method)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.reflect.Method.invoke(Method.java:525)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at dalvik.system.NativeStart.main(Native Method)
11-04 16:22:39.550: E/AndroidRuntime(25072): FATAL EXCEPTION: main51602"
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.Integer.invalidInt(Integer.java:138)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.Integer.parse(Integer.java:378)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.Integer.parseInt(Integer.java:366)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.Integer.parseInt(Integer.java:332)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at android.database.MatrixCursor.getInt(MatrixCursor.java:247)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.calendar.EventInfoFragment.initEventCursor(EventInfoFragment.java:1062)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.calendar.EventInfoFragment.access$700(EventInfoFragment.java:117)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.calendar.EventInfoFragment$QueryHandler.onQueryComplete(EventInfoFragment.java:469)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.calendar.AsyncQueryService.handleMessage(AsyncQueryService.java:412)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at android.os.Handler.dispatchMessage(Handler.java:99)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at android.os.Looper.loop(Looper.java:137)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at android.app.ActivityThread.main(ActivityThread.java:5103)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.reflect.Method.invokeNative(Native Method)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at java.lang.reflect.Method.invoke(Method.java:525)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-04 16:22:25.975: E/AndroidRuntime(25027):          at dalvik.system.NativeStart.main(Native Method)
11-04 16:22:39.550: E/AndroidRuntime(25072): FATAL EXCEPTION: main
4

0 回答 0