Java me 从lwuit表单中调用destroyApp(true)

Java me 从lwuit表单中调用destroyApp(true),java-me,lwuit,midp,Java Me,Lwuit,Midp,我想关闭一个正在运行的midlet。但当前显示的项目是lwuit表单。如何通过单击添加到lwuit表单的命令来关闭应用程序。传递midlet实例并调用destroyApp(…)或使用notifyDestroyed() 比如说, Sample.java public class Sample extends MIDlet { public Sample() { // do something new Sample1(this); // pass the MIDlet to anothe

我想关闭一个正在运行的midlet。但当前显示的项目是lwuit表单。如何通过单击添加到lwuit表单的命令来关闭应用程序。

传递midlet实例并调用
destroyApp(…)
或使用
notifyDestroyed()

比如说,

Sample.java

public class Sample extends MIDlet {

public Sample() {

  // do something
  new Sample1(this); // pass the MIDlet to another class.
 }
}
public class Sample1 {
public Sample1(final MIDlet midlet) {

  // do something
  Command exitCmd = new Command("Exit") {

            public void actionPerformed(ActionEvent evt) {
                midlat.notifyDestroyed();
            }
        };
 }
}

Sample1.java

public class Sample extends MIDlet {

public Sample() {

  // do something
  new Sample1(this); // pass the MIDlet to another class.
 }
}
public class Sample1 {
public Sample1(final MIDlet midlet) {

  // do something
  Command exitCmd = new Command("Exit") {

            public void actionPerformed(ActionEvent evt) {
                midlat.notifyDestroyed();
            }
        };
 }
}

非常感谢。成功了。我想虽然这行有一个拼写错误:midlat.notifydestromed();它是对构造函数中最后一个MIDlet“MIDlet”参数的引用。destroyApp(true)不工作:存在访问权限错误。所以我用了()来;谢谢