09-22-2011 02:24 PM
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");
}
});
}
09-22-2011 02:44 PM
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.
09-22-2011 02:58 PM
Move all your time consuming task to a separate thread...