question for terminate app in j2me but it doesnt mean quit from application

冷暖自知 提交于 2019-12-04 17:49:41

Try calling norifyDestroyed() method in MIDlet instance.

The security exception you get says it all.

J2ME applications do NOT behave like J2SE applications.

You don't start them in the same way and you don't terminate them in the same way.

In your case, the kind of J2ME application you are trying to write is called a MIDlet.

A MIDlet lifecycle is regulated by the MIDP runtime that runs on top of a Java Virtual Machine that simply executes Java bytecode and handles system resources.

When a MIDlet starts, the MIDP runtime calls the MIDlet constructor and its javax.microedition.midlet.MIDlet.startApp() override.

In order to terminate a MIDlet, the MIDP runtime calls the javax.microedition.midlet.MIDlet.destroyApp() override.

When the MIDlet decides that it can be terminated, it can call its own destroyApp() instead of waiting for the MIDP runtime to do it.

In order to tell the MIDP runtime that it can be safely terminated, a MIDlet MUST call javax.microedition.midlet.MIDlet.notifyDestroyed(), typically as the last method call in destroyApp()

I suggest reading the MIDP specifications in order to understand all the lifecycle and runtime issues.

The latest JavaME SDK also contains many properly constructed MIDlets for your inspiration.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!