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
Highlighted
New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

How to close a Dialog Alert from the background thread

Hi

 

I'm having an issue with closing the dialog alert window. I have written this applicaiton Im displaying an alert to the user but it would close when i press the ok button. after some time the whole app ends with an exception saying not responding. Any ideas about this guys?

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

Re: How to close a Dialog Alert from the background thread

"not responding" usually means you block the ui thread, for example by performing I/O on it.
----------------------------------------------------------
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: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: How to close a Dialog Alert from the background thread

Hi,

Thanks for the prompt reply..could you provide me an example as I am bit new in this...

 

Thanks you

Cheers

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

Re: How to close a Dialog Alert from the background thread

if you have networking, you need a separate thread for it.
as you posted no code and no details about your app, i am just guessing here.
----------------------------------------------------------
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: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: How to close a Dialog Alert from the background thread

btnOk.setChangeListener(new FieldChangeListener() {

				public void fieldChanged(Field field, int context) {
					// TODO Auto-generated method stub
					try{

						if(field == btnOk){

							phoneNumber = efPhoneNumber.getText().toString();
							System.out.println("User Entered Mobile Number: " + phoneNumber);
							pinNumber = efPinNumber.getText().toString();
							System.out.println("User Entered PIN Number: " + pinNumber);

							LiveGuardDBAdapter lvg = new LiveGuardDBAdapter();

							if(!lvg.TableExists())
							{
								lvg.CreateTable();
								lvg.InsertMobileNumber(phoneNumber);
							}

							else 
							{
								String mobile = lvg.getMobileNumber();
								if(!mobile.equals(phoneNumber))
								{
									lvg.UpdateMobileNumber(phoneNumber);
								}
							}							

//							UiApplication.getUiApplication().invokeLater(new Runnable()
//							{
//								public void run()
//								{
//									UiApplication.getUiApplication().popScreen(getScreen());
//								}
//							});	

							synchronized (UiApplication.getUiApplication().getEventLock())
							{
								UiApplication.getUiApplication().popScreen(getScreen());
								
							}

							signInButtonClicked(phoneNumber, pinNumber);

						}
					}catch (Exception e) {
						// TODO: handle exception
						e.printStackTrace();
					}
				}
			});

Have a look at this please simon!!! cheers

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

Re: How to close a Dialog Alert from the background thread

Kindof hard to read the code, but it looks like you are performing table inserts in the event thread.

New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: How to close a Dialog Alert from the background thread

Truee I am doing some inserts they all work fine. its just when i signIn im starting a tcp connection but i cant close the popup screen.

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

Re: How to close a Dialog Alert from the background thread

use a separate thread for ALL potentially blocking code, like tcp connections, table inserts and other I/O.
----------------------------------------------------------
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