Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jun 2008

    Unhappy MIDlet does not restart

    I trying to do a very simple MIDlet using Model-View-Controller pattern.

    It works good first time, but after exit it doesn't restart. No error message.
    Maybe I miss something about 'MIDlet life cycle' or something like that.

    Help, please.

    // Controller ======================
    package mymidlet.controller;
    import java.util.Hashtable;
    import java.util.Enumeration;
    import java.util.Vector;
    import javax.microedition.lcdui.Displayable;
    import mymidlet.MIDlet;
    import mymidlet.ui.*;
    public class Controller {
        private MyMIDlet midlet;
        private static Controller controller;    
        private StartUI startUI;
        private Hashtable uiMapping;
        private Controller(MIDlet midlet){
    	this.midlet = midlet;
        private void init(){
    	startUI = new StartUI(this);
    	uiMapping = new Hashtable();
     	uiMapping.put("startUI", startUI);
        public static final synchronized Controller getInstance(MIDlet midlet){
    	if (controller == null){
    	    controller = new Controller(midlet);
    	return controller;
        public void exit(){
        public void show(String uiName){
    	Displayable d = (Displayable) uiMapping.get(uiName);
    	if (d != null){
    // MainClass ==================
    package mymidlet;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.MIDlet;
    import midlet.controller.Controller;
    public class MyMIDlet extends MIDlet  {
        private static Display display = null;
        private Controller controller;
        public void startApp(){
    	if (display == null){
    	    display = Display.getDisplay(this);
    	if (controller == null){
    	    controller = Controller.getInstance(this);
        public void pauseApp () {}
        public void destroyApp(boolean unconditional) {}
        public void exitApp(){
    	try {
    	} catch (Exception ex){
        public void showDisplayable(Displayable d){
    // View ==================
    package mymidlet.ui;
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.List;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import mymidlet.controller.Controller;
    public class StartUI extends List implements CommandListener{
        private Controller controller;
        private final Command select = new Command("Select", Command.ITEM, 1);
        private final Command exit = new Command("Exit", Command.EXIT, 2);
        public StartUI(Controller controller){
    	this.controller = controller;
    	this.append("Exit", null);
        public void commandAction(final Command c, Displayable d) {
    	if (c == select){
    	    int selectIndex = this.getSelectedIndex();	    
    	    case 0:

  2. #2
    Nokia Developer Champion
    Join Date
    Sep 2007

    Re: MIDlet does not restart

    To restart any MIDlet you need to use push registery.

    -Kartik Trivedi

  3. #3
    Nokia Developer Champion
    Join Date
    Nov 2007
    Rome, Italy

    Re: MIDlet does not restart

    Hi nachouve,

    your code has some syntax errors (some wrong imports). Anyway, fixing those errors and testing it on both emulator and Nokia E90 it correctly restarts after exiting more times.

    On which device(s) are you testing and experiencing this issue?


  4. #4
    Registered User
    Join Date
    Jun 2008

    Re: MIDlet does not restart

    Thanks by the quick answer.

    jappit, yes... there are some mistakes on the code because I've cleaned the code on-the-fly... I'm sorry!

    I test it on the emulator and it doesn't work.

    Now, I'll try on a real device and, like in your E90, it restart correctly.
    It's very strange.

    Thank you very much.

Similar Threads

  1. How to find a phone restart between two launches of a midlet ?
    By nikhilkerala in forum Mobile Java General
    Replies: 1
    Last Post: 2007-10-16, 23:58
  2. Opening connection to the secure element fails when restarting the midlet.
    By tfroidcoeur in forum Near Field Communication
    Replies: 6
    Last Post: 2007-08-24, 08:38
  3. 技术文档:MIDP 2.0安全机制 与 MIDlet 数字签名
    By wotrust in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 0
    Last Post: 2006-12-30, 07:42
  4. 'Response Unknown' when downloading midlet
    By Weevil in forum Mobile Java General
    Replies: 3
    Last Post: 2004-05-30, 17:01
  5. How to create two instances of midlet
    By marquito99 in forum Mobile Java General
    Replies: 0
    Last Post: 2004-04-30, 01:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts