Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
venquet
Posts: 14
Registered: 08-21-2011
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");
			}
			
		});
		
		
	} 
Please use plain text.
Developer
RexDoug
Posts: 4,649
Registered: 07-21-2008

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.

 

Please use plain text.
Developer
YamilBracho
Posts: 485
Registered: 05-31-2010
My Carrier: Movistar

Re: Non Blocking Http Connection

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

Please use plain text.