Diary of a Nobody

Friday, November 10, 2006

J2ME Dough - Launching a MIDlet automatically

Well, I have been planning to write this blog for sometime but was not able to gather time and content. Anyway, so now here I am giving whatever information I have collected on launching a midlet from your application or from your server or automatically. In this article, I will not mention what all you can do, but would like to stress on what you can't do! So lets start step by step:

1) Launching a MIDlet from an Application - If you are planning to do this on MIDP 1.0 then forget it. It is not possible! I too thought that people over the net are talking crap there must be some way out, but there isn't. I wasted my one week researching the same day and night but of no use. You cannot access anything outside your holy JAR file. So you might want to check next option directly from here.
If you are using MIDP 2.0, then there is some dough for you. Its called Push Registry. In this you register/unregister a port and listen on that and blah blah blah. But here the next barrier comes in scene is that some phones do not support socket/datagram/stream connections. They are not mandatory in MIDP, its all left on the mood of manufacturer (wtf???). Even the series 60 emulators doesn't know this, thats why they have released examples with socket connection. The common error that the deviece throws is "SymbianOS error = -28 General: System error". After a little research, I concluded that this means that the connection you are trying to open is not supported by your device (n'joy!!!). So this leaves a few selecective phones for you. What I would recommend you, if you are developing a professional application then please please please check on all the phones you are releasing. Don't go by the assumption that these two are similar phones so if it is working on one phone, it will work on other too.

2) Launching a MIDlet through Web Application or WML Page - In this, sprint mobile users (U.S. Carrier) take an edge. A detailed description of how to launch midlet through webpage can be found over here. Again if you are using MIDP 1.0, least you can do is use push proxy gateway SI request. I haven't tried this myself because the process was too complicated and I have least knowledge of the same. But this is the only possible solution I think, for MIDP 1.0.
For MIDP 2.0 users, push registry again comes in to picture. You can register an application to listen on a specific port for SMSes. An then send a request from WML Page to your server and server will send the SMS on the respective port. This is a better solution then launching a MIDlet through Application, as here the tension of looking for possible connections on each and every mobile phone obviates.

3) Launching a MIDlet automatically - well, as always J2ME imposes its restrictions in here too. If you want to launch a midlet during boot then all you have to do is resgister on port 8099. I haven't tried this myself but all over the net its the same, so I guess it must be true! Other possible scenarios are, if you want to launch a MIDlet at a specified time then you can do it again via Push Registry in MIDP 2.0. In MIDP 1.0 this can't be done.

So, overall to conclude, in MIDP 1.0 only way to launch a MIDlet is via Push Proxy service and in MIDP 2.0 it is more flexible, but erratic, because of Push Registry which is more or less meant for this purpose only.

Labels: , ,