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
Posts: 84
Registered: ‎01-10-2013
My Device: Bold 9900
My Carrier: China Unicom
Accepted Solution

Dialog.alert() can not display in implements method

class DialogCommandHandler extends CommandHandler
{
	public void execute(ReadOnlyCommandMetadata metadata, Object context)
	{
		if (context.equals(contextSearch)) {
			Dialog.alert("Coming soon!");
		}
	}
}

 

Hi, everyone, I found this problem while I'm debugging my app, the execute implements net.rim.device.api.command.CommandHandler.execute, in this implements the Dialog.alert() can not display my alert message, I have been tried invokeLater() and invokeAndWait() with/without synchronized (Application.getEventLock()) {}, all of them didn't worked correctly, is there any solution for this problem, or it is an issue? Thanks!~

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Dialog.alert() can not display in implements method

Can you describe what happens?  Is there an exception thrown?  Or does the processing just stop?

 

In this case, I think the correct 'packaging' for this, is an invokeLater.  I think the other options will cause a deadlock.  So your code will be something like:

 

if (context.equals(contextSearch)) {

UiApplication.getUiApplication.invokeLater(new Runnable() {

public void run() {

Dialog.alert("Coming soon!");

}

});
}

Developer
Posts: 84
Registered: ‎01-10-2013
My Device: Bold 9900
My Carrier: China Unicom

Re: Dialog.alert() can not display in implements method

thanks, peter, I found the problem, there's a math calculate got some error, and it doesn't throw any exceptions Smiley Happy