Boot to start automatically midlet has been the dream of J2ME developers, a dream that has been realized on Sony Ericsson's JP7 platform. However, it should be noted that the early models are not supported, such as K790. Please refer to the Sony Ericsson Manual for details.
The power-on self-boot function is done by push registration, so you can register it in two different ways. The first way to sign a push registration in a JAD file is as follows.
Midlet-push-<n>: <connectionurl>, <midletclassname> <AllowedSender>
Midlet-push-1: autostart://:, Autostartstatic, *
Please note that the URL is written autostart://:
If you want to register dynamically, you can use the following method.
//registers the Pushregistry
public void Register () {
//List of registered push connections.
String connections[];
//Check to the If the connection has been registered.
//This is a dynamic connection allocated on the I//time execution the this MIDlet.
Connections = Pushregistry.listconnections (false);
if (connections.length = = 0) {
try {
//register so the MIDlet'll wake up when phone is started.
Pushregistry.registerconnection ("autostart://:", "Autostartdyn", "*");
Sdisplaystring = "MIDlet is registered";
} catch (Exception ex) {
System.out.println ("Exception:" + ex);
sdisplaystring = "Fail:" + ex;
}
Else {
Sdisplaystring = "already registered";
}
Displayform.deleteall ();
Displayform.append (sdisplaystring);
}
Unregisters the Pushregistry
public void Unregister () {
if (Pushregistry.unregisterconnection ("autostart://:")) {
System.out.println ("The Pushregistry is unregistered");
sdisplaystring = "MIDlet is unregistered.";
}else{
System.out.println ("There is no pushregistry to unregister");
sdisplaystring = "No MIDlet to unregister or failed to unregister";
}
Displayform.deleteall ();
Displayform.append (sdisplaystring);
}
Since there is no SonyEricsson JP7 platform on hand, there is no way to test the boot auto start function. If you have the conditions, you can test it yourself.
Original address: http://developer.sonyericsson.com/site/global/techsupport/
tipstrickscode/java/p_autostarting_jp7midlets.jsp