1

I am trying to get Events out of the users device calendar with this code:

    Date from = new Date();
    java.util.Calendar c = java.util.Calendar.getInstance();
    c.add(java.util.Calendar.MONTH, 1);
    Date to = c.getTime();
    String calendarId = dc.openCalendar(calenderName, false);

    Collection <EventInfo> events = dc.getEvents(calendarId, from, to);

The last line is where the Exception is thrown and I have absolutely no idea why.

I cant deliver any Exception Messages since the CN1Lib cant be debugged within the ide or the simulator, which makes it really hard to find the bug here.

When getting to the Exception it is just telling me:

Error
An internal application error occurred: java.lang.ArrayIndexOutOfBoundsException: null

Thanks in advance

Max R.
  • 1,574
  • 2
  • 12
  • 27

1 Answers1

1

DeviceCalendar is not supported in the Simulator so it will always throw an Exception.

You can only get events on a device and to debug this code snippet on a device, wrap it in try-catch and use Log.sendLog() to get the StackTrace in the email you are using with Codename One.

Remember to remove the Log.sendLog() when you're done, otherwise, you may be spammed with error log emails.

try {
    //DeviceCalendar Code snippet here
} catch (Exception ex) {
   Log.e(ex);
   Log.sendLog();
}
Diamond
  • 7,428
  • 22
  • 37
  • Unfortunately I am just a poor student and can only afford the basic Codename One, so I don't have access to the Pro-only feature sendLog(). Is there any other way to find out whats is wrong? The usage of the DeviceCalendar seems pretty trivial to me, so I'm curious what could be going wrong in my code. – Max R. Mar 28 '17 at 15:53
  • You can hook up your device and view the log in logcat, or Android Studio. There are also apps you can install that will let you view the log. http://stackoverflow.com/questions/3707880/using-adb-logcat-with-a-real-phone-and-not-the-emulator – steve hannah Mar 28 '17 at 17:01