Sign in to follow this  
Goguigo

Command Listener Options.

Recommended Posts

Hey guys. I'm having some trouble here with this. I created an option for the menu of the softkeys, but, when i try it in any mobile hand set, it doesn't appear. What's wrong with it? Thanks
[source code=javax]
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class MainBase extends MIDlet implements CommandListener
{
	private Display desplegar;
	private Command comandoSalir;//Comando de Salida
	private GameAlfaClass comic;
	public int opcion=99;
	public boolean isPlay=true;
	public boolean isOut=true;
	public void startApp() throws MIDletStateChangeException
	{
		desplegar = Display.getDisplay(this);
		program=new GameAlfaClass(this);
		comandoSalir = new Command("Correr",Command.EXIT,2);
		program.addCommand(comandoSalir);
		program.setCommandListener(this);
		try
		{
			program.start();
			desplegar.setCurrent(comic);    
			isOut = true;
			while (isOut){}    
			program.stop();
			program = null;

		}
		catch (Exception ex)
		{
			System.out.println(ex);
			
		}
		notifyDestroyed();
	}
	public Display getDisplay()
	{
		return desplegar;  
	}
	public void pauseApp()
	{
		program.stop();
		
		try { Thread.sleep(1000); }//esperar medio segundo para dar consistencia
		catch (InterruptedException ie) {}
	}
	public void destroyApp(boolean unconditional)
	{
		program.stop();
		
		try { Thread.sleep(1000); }//esperar medio segundo para dar consistencia
		catch (InterruptedException ie) {}
		
	}
	public void commandAction(Command c, Displayable s) 
	{
		if (c == comandoSalir) 
		{
			destroyApp(true);
		} 
	}
}





[/source code]

Share this post


Link to post
Share on other sites
Hey guys, i fixed it. :)

lol.

You just CAN't give an exit option without giving a CANCEL one... so, that's why it bringed up the conflict. Thanks anyway. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this