Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
spiv
Posts: 21
Registered: ‎10-09-2008
My Device: Not Specified

invokeApplication APP_TYPE_CALENDAR not working in 4.2.1 ?

In 4.3, we added a menuItem in the BB calendar application. It creates a new appointement and populate all the fields so that the user has just to invite attendees and save. It works well.

We tried this en 4.2.1, unfortunatly it doesn't work. When we try to invoke a new appointement from our custom menu item in the BB calendar application, nothing happens. In debug, no exception is thrown. We tried to invoke the adress book application and it worked but not the calendar app. So it seems impossible to add a new appointement from the calendar app. Is it because we are already in the calendar app ? Is it a bug (because it works in 4.3) ?

Here is some code :

 

 

public class MyMenuItem extends ApplicationMenuItem { //... public Object run(Object context) { try {

 

Event event = (Event)context; //... EventList el = null; try {

 

el = (EventList)BlackBerryPIM.getInstance().openPIMList( BlackBerryPIM.EVENT_LIST, BlackBerryPIM.READ_WRITE );

 

} catch (PIMException ex1) { ex1.printStackTrace(); } Event e = el.createEvent(); e.addString(Event.NOTE, 0, "test"); Invoke.invokeApplication( Invoke.APP_TYPE_CALENDAR, new CalendarArguments( CalendarArguments.ARG_NEW, e)); } catch (IllegalArgumentException ex2) { ex2.printStackTrace();

}

 

return context;

} }

 

 Regards,

 

Sylvain.

 

Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: invokeApplication APP_TYPE_CALENDAR not working in 4.2.1 ?

I've had similar issues.

 

Based on my own experience (not necessarily official gospel), you need to be calling Invoke() from your own event thread. Calling this from within a listener thread is not going to work.

 

You might try using creating a runnable object that calls the Invoke of the calendar, then pass this runnable off to UiApplication.invokeLater().

 

Of course, there are several ways to skin this cat and I'm sure other folks have their own methods of getting it done. If you search this forum for "invokeLater" or "event thread" you will probably find 20 similar issues and solutions.

 

 

Developer
spiv
Posts: 21
Registered: ‎10-09-2008
My Device: Not Specified

Re: invokeApplication APP_TYPE_CALENDAR not working in 4.2.1 ?

Thx RexDoug.

 

I tried this :

 

 

UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Invoke.invokeApplication( Invoke.APP_TYPE_CALENDAR, new CalendarArguments( CalendarArguments.ARG_NEW, e )); } });

 

But that doesn't work...

 

Any other ideas ?

 

 

Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: invokeApplication APP_TYPE_CALENDAR not working in 4.2.1 ?

 

Try this:

 

1. in your Runnable, call UiApplication.requestForeground()

 

2. In your UiApplication.activate() method, perform the Invoke on calendar.

Developer
spiv
Posts: 21
Registered: ‎10-09-2008
My Device: Not Specified

Re: invokeApplication APP_TYPE_CALENDAR not working in 4.2.1 ?

Thanks for replying again, we tried but without success.

 

We discovered (from the support) that in 4.2.1 we cannot invoke a calendar item if the calendar application is already opened.

 

However, we found another way to do that. Our code now invokes an UIApplication that wait 1 second and invoke a calendar item. Just after invoking this application, we close the current active screen which is the calendar application (the UIApplication is waiting at this moment).

 

It's not very satisfaying but it's the only way we found to do the job.

 

Regards,

 

Sylvain.