View Single Post
Old 11-24-2008, 10:38 AM   #7 (permalink)
sickned
Knows Where the Search Button Is
 
Join Date: Oct 2008
Model: 7100T
PIN: N/A
Carrier: Unknow
Posts: 42
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Ivanov.

I've tried to use callbacks, but when I call the new Thread (who calls WS), the principal thread stay suspended or something.

I'll show you some code:

Code:
public class InicioThread extends Thread{
	
	PretiumController controller;
	InicioScreen screen;
	
	public InicioThread(PretiumController controller, InicioScreen screen){
		this.controller = controller;
		this.screen= screen;
	}
	
	public void run() {
		try {
			sleep(1000);			
			controller.inicializarApp(); //THIS CALLS THE WS
			screen.inicializarAplicación();
		} catch (Exception e) {
			screen.informarExcepción(e.getMessage());
		}
		
	}
	
}


public class InicioScreen extends MainScreen {
			
	PretiumController  controller;
	
	
	public InicioScreen(PretiumController controller){
		this.controller = controller;
		
		InicioLabelField inicio = new InicioLabelField(controller, "Iniciando aplicación...");
		
		add(inicio);	
		
		
		

	}
	
	
	
	public  void inicializarAplicación(){
		
			try{			
				UiApplication.getUiApplication().pushScreen(new SeleccionClienteScreen(controller));
				
			}catch(Exception e){
				Dialog.inform(e.getMessage());
			}
			
		
	}
	
	public void lanzarThread(){
		InicioThread t = new InicioThread(controller, this);
		t.run();
	}
	
	public void informarExcepción(String mensaje){
		Dialog.inform(mensaje);
	}


}

public class PretiumMain extends UiApplication{

	public static void main(String[] args) {
		PretiumMain theApp = new PretiumMain();		
		theApp.enterEventDispatcher();	
		
	}

	public PretiumMain() {

			PretiumController controller = new PretiumController();
			
			InicioScreen inicio = new InicioScreen(controller);
			
			UiApplication.getUiApplication().pushScreen(inicio);
			
			inicio.lanzarThread();
			
			
	
	}
}
What Im doing wrong?

Last edited by sickned : 11-24-2008 at 10:39 AM.
Offline   Reply With Quote