Writing Events Tasks or Contact to Device Calendar Tasks or Address Book

epeer's picture

Writing code to add an event to the RIM calendar as the sample below will not actually save it or appear in the calendar of the device if you escape out of the form after you run the function. It will only save it if you use MainForm.Display() to navigate to the application initial form after running the function.

Does anybody know why? Is there another way to commit the Event Task or Contact without navigating to a different form or Ending the application?

BTW, that’s how it works on the simulator, didn’t try it on the actual device yet.

var evt = Event.create();
evt.start = start;
evt.end = end;
evt.summary = summary;
evt.location = "Office";
var alm = new Date(start);
alm.setMinutes(alm.getMinutes() - 60, 0, 0);
evt.alarm = alm;

Trackback URL for this post:

http://blackberry.developercommunity.com/trackback/510
Champion
adam's picture

If you're looking for something BlackBerry specific, use EventList and Event found in the net.rim.blackberry.api.pim namespace. It should save the event into the Calendar with no problems.

----------------------------
EventList _evL = (EventList)PIM.getInstance().openPIMList(PIM.EVENT_LIST,PIM.READ_WRITE);
Event evt = _evL.createEvent();
...

----------------------------
Note: If you are developing strictly for the BlackBerry, I believe you can also use a BlackBerryEvent object instead of an Event object.

You may have to call the evt.commit() method to save the calendar entry... I'm not entirely sure.

epeer's picture

thank you for your responce.
but the "Visual Studio Plugin" dosen't have all these classes available, only the built ins.

Champion
adam's picture

Sorry... didn't realize this was in the Visual Studio Plugin section.

Have you allowed your application to access PIM data through the Application Permissions on the handheld? If you're testing on a real device (as opposed to the simulator), you may need to allow this on the BES server as well through an IT policy.