March 25, 2007

[J2ME] Open browser or download a MIDlet from J2ME

platformRequest
MIDP2.0 of J2ME has ability to invoke the browser in the phone. It can tell the browser to open a URL, or download and install a MIDlet. Here is the method:

javax.microedition.midlet.MIDlet.platformRequest()

boolean platformRequest(java.lang.String URL)
Returns true if the MIDlet suite must exit before the external platform service can be invoked. Throws a ConnectionNotFoundException if the platform cannot handle the URL argument. E.g.

platformRequest(http://www.google.com);
platformRequest(
http://www.j2medeveloper.com/ota/basicpush.jad);


Test it in your emulator

Before running it on the emulator, you need to do some configurations in the WTK. You need to add the following the the system.config (in the lib folder of the WTK) :

# firefox browser example
com.sun.midp.midlet.platformRequestCommand: "C:\Program Files\Mozilla Firefox\firefox.exe"


Note: Device manufacturers, e.g. Nokia, Sony, Motorola, are free to implement addition platform services.

No comments: