如何停止j2me的midlet的执行?

发布于 2024-10-06 07:45:35 字数 33 浏览 0 评论 0原文

如何停止j2me midlet的执行一段特定的时间?

How to stop the execution of midlet of j2me for a specific amount of time ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城月光淡如水﹏ 2024-10-13 07:45:35

MIDlet的生命周期完全由驻留在手机上的AMS软件控制。因此,任何与 MIDlet 执行相关的功能都必须向 AMS 软件请求。对于您所描述的特定情况,PushRegistry 支持。

您可以通过指定 MIDlet 的完全限定类名以及应用程序必须再次启动的时间(以毫秒为单位)来使用 registerAlarm。请注意,这是绝对时间。它的工作方式如下:

  1. 在您的应用程序中,注册闹钟以及应用程序需要唤醒的时间。例如,您希望应用程序在 10 分钟后启动。那么参数必须是 com.yourcompany.app.AppMIdlet、Date().getTime()+ 600000。
  2. 现在,退出应用程序。
  3. 喝一杯啤酒,等待 10 分钟
  4. Boom!应用程序将在 10 分钟后启动。
  5. 利润!

注意:这是一个受保护的 API,应用程序可能必须签名才能使用它。大多数手机都会有安全提示;但很少有人不这样做。这取决于制造商和运营商制定的政策。因此,正确捕获安全异常;否则你会对应用程序默默地失败感到困惑。

参考文献:

  1. [PushRegistry的注册警报,API规范][1]
  2. 非常彻底PushRegistry论文

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

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文