Programming Tutorials

(追記) (追記ここまで)

java.lang.SecurityException: MIDP lifecycle does not support system exit.

By: Henry in J2ME Tutorials on 2007年09月16日 [フレーム]

The java.lang.SecurityException: MIDP lifecycle does not support system exit error occurs when you attempt to use the System.exit() method in a Java ME MIDlet. This is because Java ME has its own lifecycle management and doesn't allow the application to terminate itself.

Instead of using System.exit(), you can gracefully terminate the application by calling destroyApp() method of MIDlet class. Here's an example:

import javax.microedition.midlet.*;
public class MyMIDlet extends MIDlet {
 public void startApp() {
 // Your application code here
 }
 public void pauseApp() {
 // Your application code here
 }
 public void destroyApp(boolean unconditional) {
 // Your application cleanup code here
 notifyDestroyed();
 }
}

In this example, the destroyApp() method is called when the application is about to be terminated. You can put your cleanup code in this method. The notifyDestroyed() method is called to notify the application management software that the MIDlet has terminated.




(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /