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
New Developer
Posts: 53
Registered: ‎06-07-2011
My Device: 9800 torch
My Carrier: o2
Accepted Solution

Dialog creating RunntimeException on OS5

I have a Dialog.D_YES_NO asking a question and on the no result i want it to pop a screen. however I'm always getting a RunnTimeException. This only happens on the no result not on the yes result, which is weird since the yes result leads into the no result. And only on OS5 OS6 is fine.

 

catching the Exception isnt possible either, it doesn't get thrown up

 

 

code:

ZoomScreen zoomableEncodedRawImage = new ZoomScreen(encodedRawImage);
				        UiApplication.getUiApplication().pushScreen(zoomableEncodedRawImage);
				        
				        switch(Dialog.ask(Dialog.D_YES_NO, "Accept image", Dialog.YES))
				        {
				        case Dialog.YES:
				        	doSomething(rawImage);
				        case Dialog.NO:
				        	synchronized (Application.getEventLock()) {
				        		UiApplication.getUiApplication().popScreen(zoomableEncodedRawImage);
							}
				        	break;
				        }

 

New Developer
Posts: 53
Registered: ‎06-07-2011
My Device: 9800 torch
My Carrier: o2

Re: Dialog creating RunntimeException on OS5

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

Re: Dialog creating RunntimeException on OS5

Just a guess, but I think this problem is possibly related to you not giving up the Event Thread.

 

Can you change:

synchronized (Application.getEventLock()) {
UiApplication.getUiApplication().popScreen(zoomableEncodedRawImage);
}

to

Screen finalScreen = zoomableEncodedRawImage;

UiApplication.getUiApplication()invokeLater(new Runnable() {

public void run() {

UiApplication.getUiApplication().popScreen(finalScreen);

}

}

 

If this doesn't help, can you tell us what the Runtime Exception actually is and what the associated detail message is.

 

In general, I would avoid using

synchronized (Application.getEventLock()) { }

as the standard approach to handling the Ui.  Only use it when you need to.  use invokeLater when you don't need too. 

New Developer
Posts: 53
Registered: ‎06-07-2011
My Device: 9800 torch
My Carrier: o2

Re: Dialog creating RunntimeException on OS5

i put the sync block in because I thought that was what was causing the exception. That the thread didnt have an eventLock. Odd since its done in the UI thread.

I cant actually catch the exception so cant get the detailed message. it gets "handled" somewhere between it getting thrown and before it gets back to my code.

I'll try your way
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Dialog creating RunntimeException on OS5

you can check the device log (alt+lglg) for details of the uncaught exception.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 53
Registered: ‎06-07-2011
My Device: 9800 torch
My Carrier: o2

Re: Dialog creating RunntimeException on OS5


peter_strange wrote:

Just a guess, but I think this problem is possibly related to you not giving up the Event Thread.

 

Can you change:

synchronized (Application.getEventLock()) {
UiApplication.getUiApplication().popScreen(zoomableEncodedRawImage);
}

to

Screen finalScreen = zoomableEncodedRawImage;

UiApplication.getUiApplication()invokeLater(new Runnable() {

public void run() {

UiApplication.getUiApplication().popScreen(finalScreen);

}

}

 

If this doesn't help, can you tell us what the Runtime Exception actually is and what the associated detail message is.

 

In general, I would avoid using

synchronized (Application.getEventLock()) { }

as the standard approach to handling the Ui.  Only use it when you need to.  use invokeLater when you don't need too. 


code currently. 

 

final ZoomScreen zoomableEncodedRawImage = new ZoomScreen(encodedRawImage);
				        UiApplication.getUiApplication().pushScreen(zoomableEncodedRawImage);
				        
				        switch(Dialog.ask(Dialog.D_YES_NO, "Accept image", Dialog.YES))
				        {
				        case Dialog.YES:
				        	doSomething(rawImage);
				        case Dialog.NO:
				        		UiApplication.getUiApplication().invokeLater(new Runnable() {
									
									public void run() {
										UiApplication.getUiApplication().popScreen(zoomableEncodedRawImage);
									}
								});
				        	break;
				        }
	    			}

 still getting a RuntimeException. With the debugger attached it "ignores" this exception and does what's expected but when not attached it goes to the white exception screen

 

thoughts?

New Developer
Posts: 53
Registered: ‎06-07-2011
My Device: 9800 torch
My Carrier: o2

Re: Dialog creating RunntimeException on OS5


simon_hain wrote:
you can check the device log (alt+lglg) for details of the uncaught exception.

how do you do this on the storm simulator?

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Dialog creating RunntimeException on OS5

http://btsc.webapps.blackberry.com/btsc/viewdocument.do;jsessionid=838A2136128C3626CF845CF0F41E9489?...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 53
Registered: ‎06-07-2011
My Device: 9800 torch
My Carrier: o2

Re: Dialog creating RunntimeException on OS5

ok finally got a detail message. Claims the touch input event has expired and is invalid
New Developer
Posts: 53
Registered: ‎06-07-2011
My Device: 9800 torch
My Carrier: o2

Re: Dialog creating RunntimeException on OS5

any ideas guys, really need to get this sorted.

 

So odd that it only happens on the "No" button but it's a standard Blackberry Dialog so others should've come against it. Help please