Hey back !

Bon alors mon problème est le suivant :

Je veux lancer un MIDlet principal qui choisira ensuite dynamiquement le MIDlet à éxécuter.

Pour faire ceci, il me faut être en mesure de lancer un MIDlet à partir d'un autre MIDlet.

Or, la méthode présentée sur la plupart des réponses internet semble ne pas fonctionner.

Voici mon code, inspiré de la javadoc elle même me semble t-il :

MIDlet principal :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
import java.util.Date;
import javax.microedition.io.PushRegistry;
import javax.microedition.midlet.*;
 
/**
 * @author Skip
 */
public class choiceMidlet extends MIDlet {
    public void startApp() {
        int	i;
		String	incoming[];			// list of incoming connections
 
		System.out.println( "choiceMIDlet:startApp()" );
 
		try {
			long previous;
			Date now = new Date();
 
			previous = PushRegistry.registerAlarm( "satsaMIDlet", now.getTime() + 60000 );
 
			System.out.println( "choiceMIDlet: time of previous alarm: " + previous );
		} catch ( java.lang.ClassNotFoundException cnf ) {
			System.out.println( "satsaMIDlet: Class Not Found" );
		} catch ( javax.microedition.io.ConnectionNotFoundException connnf ) {
			System.out.println( "satsaMIDlet: Connection Not Found" );
		}
 
		System.out.println( "ChoiceMIDlet:startApp: return" );
 
		// self terminate, there is nothing else to do
 
		notifyDestroyed();
    }
 
    public void pauseApp() {
    }
 
    public void destroyApp(boolean unconditional) {
    }
}
MIDlet appelé :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
 
 
import javax.microedition.midlet.*;
 
/**
 * @author Skip
 */
public class satsaMIDlet extends MIDlet {
 
    public satsaMIDlet(){
        System.out.println("IN constructor");
    }
 
    public void startApp() {
        System.out.println("IN");
    }
 
    public void pauseApp() {
    }
 
    public void destroyApp(boolean unconditional) {
        this.notifyDestroyed();
    }
}
Sortie (ne passe pas par le MIDlet appellé) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
choiceMIDlet:startApp()
choiceMIDlet: time of previous alarm: 0 // (correspond au premier appel de l'alarm => semble être normal.
choiceMIDlet:startApp: return
Plz help


P.S. Je préciserai que je suis dans la même MIDletSuite et que mon .jad ressemble à ca :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
MIDlet-1: choiceMidlet, ,choiceMidlet
MIDlet-2: satsaMidlet,,satsaMIDlet
MIDlet-Jar-Size: 2329
MIDlet-Jar-URL: BCorSATSA_launcher.jar
MIDlet-Name: BCorSATSA_launcher
MIDlet-Permissions-Opt: javax.microedition.io.PushRegistry
MIDlet-Vendor: Vendor
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0