Jump to content
  • Advertisement
Sign in to follow this  
Woody FX

Closing Midlets Series 60 problem.

This topic is 4992 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been using the same code for a few games to close MIDlets and it works on Series40 phones and on S60 emulators. I have got an S60 to test on and i get an null pointer exception when i close the app. The app closes (or it seems to) then the exception comes up on the screen. I think the KVM stays running since the battery always runs down over night to flat. How are you closing your S60 apps? Are there some known problems? Phone is the 6670. Thanks Guys!

Share this post


Link to post
Share on other sites
Advertisement
Could have told you this one in e-mail. I noticed this problem with some of our games and worked out how to exit it. Press and hold the switch task (circle one) button until the task list comes up, select the running app and press c. It will ask if you want to exit taht particular apps.

Share this post


Link to post
Share on other sites
I think he meant the actual code. What I do boils down to this:


public class MyMIDlet extends MIDlet
{
/** Display */
private Display display = null;
private MyCanvas curCanvas = null;

/** Constructor. */
public MyMIDlet ()
{
//Get display
display = Display.getDisplay (this);

//Create canvas
curCanvas = new MyCanvas (this);
display.setCurrent (curCanvas);

//Start running
Thread thread = new Thread (curCanvas);
thread.start ();
}

/** No need to handle start. */
public void startApp () {}
/** No need to handle pause. */
public void pauseApp () {}
/** No need to handle destruction. */
public void destroyApp (boolean unconditional) {}
}




public class MyCanvas extends Canvas implements Runnable, CommandListener
{
//Parent MIDlet
private MyMIDlet parent;

//Exit flag
boolean mustExit;

/**
* Constructor.
*
* @param p The MyMIDlet owning this canvas.
*/

public MyCanvas (MyMIDlet p)
{
//Store handle
parent = p;
}


/**
* Handle a UI command. Event handler for user interface events. There's
* only one events: <code>EXIT</code>.
*/

public void commandAction (Command command, Displayable displayable)
{
switch (command.getCommandType ())
{
case Command.EXIT :
endMIDlet ();
break;
}
}

/**
* Shut down the game.
*/

protected void endMIDlet ()
{
mustExit = true;
}

/**
* Main loop.
*/

public void run ()
{
while (!mustExit)
{
//Do stuff here
}

//All done
parent.notifyDestroyed ();
}

/** Unused event handlers and inherited functions */
protected void paint (Graphics g) {}
protected void keyPressed (int keyCode) {}
protected void keyReleased (int keyCode) {}
protected void keyRepeated (int keyCode) {}
protected void pointerDragged (int x, int y) {}
protected void pointerPressed (int x, int y) {}
protected void pointerReleased (int x, int y) {}
}



That's pretty much all.

Share this post


Link to post
Share on other sites
Make sure you are not leaving any threads running in the background by mistake. This can cause the exact symptoms you described - destroyApp() throws what should be a MIDletStateChangeException, but on Series 60 ends up being a NullPointerException (this platform seems to have a high rate of NullPointerExceptions that should be some other kind of exception), and the MIDlet keeps on running that zombie thread until you force a close the way pkelly described. You could also try sending true to the unconditional argument of destroyApp().

shmoove

Share this post


Link to post
Share on other sites
I take it this problem is only on phones with the Symbian OS then! As it keeps process going sort of like Windows if not shut down properbly.

Thanks guys! Will give that a try and see if it works!

Brian

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!