Launching a MIDlet from another MIDlet

In both Series 40 and Symbian (Java Runtime 2.1 for Symbian onwards), MIDlets can be launched with platformRequest using the localapp: scheme. For example:

platformRequest("localapp://jam/launch?midlet-name=ArcadeGames;midlet-vendor=Acme;sounds=OFF;difficulty=easy;wizard_mode=ON"); 

The MIDlet to be launched is identified by the combination of the MIDlet suite name (midlet-name), vendor (midlet-vendor). In case the suite has multiple MIDlets, the MIDlet needs to be identified with MIDlet number (midlet-n).

The midlet-name, midlet-vendor and midlet-n attribute values are case sensitive. They must match their corresponding attribute values of MIDlet-Name, MIDlet-Vendor and <n> in MIDlet-<n>.

In Symbian, the application declares the parameters it supports using the Nokia-MIDlet-Launch-Params JAD/JAR manifest attribute . The application can access the parameters through system properties. Parameters not listed in Nokia-MIDlet-Launch-Params are not passed to the application. For example, the MIDlet Acme/ArcadeGames needs to define the following attribute (Symbian only):

Nokia-MIDlet-Launch-Params: sounds,difficulty,wizard_mode

The ArcadeGames MIDlet can access the parameters as follows:

System.getProperty("sounds");
System.getProperty("difficulty");
System.getProperty("wizard_mode"); 

From Java Runtime 2.1 for Symbian onwards, also the javaapp: scheme can be used for launching MIDlets.

platformRequest("javaapp:midlet-name=ArcadeGames;midlet-vendor=Acme;sounds=OFF;difficulty=easy;wizard_mode=ON");

In Symbian, when a MIDlet starts, it can acquire the full command line from system property com.nokia.mid.cmdline.

In Symbian , a MIDlet can also be launched using the MIDlet's UID. The MIDlet UID can be in hexadecimal or decimal format. For example:

platformRequest("javaapp:midlet-uid=0xE1000000;sounds=OFF;difficulty=easy;wizard_mode=ON);

Chaining MIDlets in Series 40

A Manufacturer/Operator signed MIDlet can use the platformRequest method (which is specified in MIDP2 specification) to invoke other MIDlets installed on the phone via the localapp URI scheme. After a successful MIDlet launch and exit of the target MIDlet, the user can be returned to the MIDlet that initiated this invocation by specifying the additional parameter chaining=true in the platformRequest URI.

This behavior is called 'MIDlet chaining' where MIDlet A invokes MIDlet B, and the user is taken back to MIDlet A after the exit of MIDlet B.

For example localapp://jam/launch?midlet-name=NokGolf;midlet-vendor=Nokia;midlet-version=1.2;chaining=true

Dependencies and platform restrictions:

  • By default 'MIDlet chaining' is disabled. Not specifying this parameter in the URI is equivalent to chaining=false.

  • In order to use the feature, the device needs to support JSR 211 Content Handler API.

  • This feature is restricted to MIDlets belonging to Manufacturer and Operator domain.

  • In case of a MIDlet suite with multiple MIDlets, this method will always invoke the MIDlet specified by the MIDlet-1 attribute in the JAD file; that is, the first MIDlet in the suite.

  • In Symbian the parameter is ignored. As multitasking is supported, 'MIDlet chaining' is in a sense always enabled.

An example snippet of code specifying the method use follows:

public class xyzMIDlet extends MIDlet{

	//.....................
	//......................

	String url = "localapp://jam/launch?midlet-name=NokGolf;midlet-vendor=Nokia;chaining=true";

	if (platformRequest(url)){
		System.out.println("midlet exit required");
		notifyDestroyed();
	}
	else
	{
		System.out.println("midlet exit NOT required");
	}
	//.....................
	//......................

} // end of MIDlet class