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
Contributor
Posts: 14
Registered: ‎08-21-2011
My Device: Bold
My Carrier: Airtel

Non Blocking Http Connection

Have login screen, during authentication if my Wifi or 3G network goes down application remains unresponsive even I cant go to home screen by pressing hang-off button (red), only option is by pressing menu buttong to dispay switch over.Please advise..how to handle without blocking the UI

 

This is how handled..



private void connectToServer()
{
final PopupScreen pop1 = new SMProgress().getPopUp("Authentication In-progress...");
		//
		UiApplication.getUiApplication().invokeLater(new Runnable()
		{
			public void run()
			{
			
				UiApplication.getUiApplication().pushScreen(pop1);
				
			}
			
		});
		
		
		UiApplication.getUiApplication().invokeLater(new Runnable()
		{
			public void run()
			{
				disableUi();
			
				boolean t = doLogin(txtUN.getText(), txtPass.getText());
				
			    UiApplication.getUiApplication().popScreen(pop1);
				
				UiApplication.getUiApplication().repaint();
				if(t) {
					UiApplication.getUiApplication().pushScreen(new IndexScreen(LoginScreen.this));
				}
				else
				{
					
					enableUi();
// Authentication failed..
				}
				
				System.out.println(" AM DONE.... 2");
			}
			
		});
		
		
	} 
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Non Blocking Http Connection

Looks to me like you are doing the login in the UI event thread. You'll need to put the HTTP in a separate worker thread.

 

The HTTP worker thread would then have to notify the UI with the result of the login.

 

Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Non Blocking Http Connection

Move all your time consuming task to a separate thread...