开发者

How to stop the execution of midlet of j2me?

H开发者_Go百科ow to stop the execution of midlet of j2me for a specific amount of time ?


MIDlet's life cycle is completely controlled by AMS software resident on the phone. So, any facility that is related to execution of MIDlet must be requested from AMS software. For the particular situation you are describing is supported by Push Registry.

You could use registerAlarm by specifying the fully qualified class name of the MIDlet and time (in milli seconds) at which the application must be started again. Note that this is absolute time. The way it works is as follows:

  1. In your application, register alarm with the time at which the application needs to wake up. For example, you would want the application be launched after 10 mins. Then the arguments must be com.yourcompany.app.AppMIdlet, Date().getTime()+ 600000.
  2. Now, exit the application.
  3. Have a mug of beer, while you wait for 10 mins
  4. Boom! Application launches after 10 mins.
  5. Profit!

Note: This is a protected API and it is possible that application MUST be signed in order to make use of it. Most of the phones would allow with a security prompt; however there are few that don't. It depends on the policy set by manufacturer and operator. So, catch security exceptions properly; otherwise you will be puzzled that app fails silently.

References:

  1. [Push Registry's register alarm, API spec][1]
  2. A very thorough treatise of Push Registry

    [1]: http://download.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/javax/microedition/io/PushRegistry.html#registerAlarm(java.lang.String, long)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜