views:

288

answers:

1

Hi,

I created a custom menu item inside the Blackberry Calendar Event Viewer which opened another screen. When the screen is closed, something was changed on the event and was committed. However the following code can not refresh the contents in Event Viewer.

The following code is inside the method onClose() of the screen and is after the closing the screen.

UiApplication.getUiApplication().invokeLater(new Runnable()
{
    public void run()
    {
        try
        {
            event0.setString(Event.NOTE, 0, 
                PIMItem.ATTR_NONE, "blahblan");
            event0.commit();
            //The active screen is Event Viewer. I tested it.
            Screen screen = 
                UiApplication.getUiApplication().getActiveScreen();
            screen.invalidate();
        }
        catch(Exception pexp)
        {
            return;
        }
    }
});

Thanks in advance.

A: 

Maybe event is updated only in Event View screen constructor...

Workaround is to close and open Event View screen... using event injections

mEvent.commit();
// The active screen is Event Viewer. I tested it.
Screen screen = UiApplication.getUiApplication().getActiveScreen();
UiApplication.getUiApplication().popScreen(screen);
KeyEvent event = new KeyEvent(KeyEvent.KEY_DOWN, Characters.ENTER,
    KeyListener.STATUS_NOT_FROM_KEYPAD);
event.post();

Don't forget to Allow Application Permission -> Interaction -> Input Simulation.
Or request it pragmatically (How to give blackberry application all the available permission?)

Max Gontar