I want to close a running midlet. But the current item on Display is a lwuit Form. How can I close the app by clicking a Command added to an lwuit Form.
pass midlet instance and call destroyApp(...)
or use notifyDestroyed();
.
For example,
Sample.java
public class Sample extends MIDlet {
public Sample() {
// do something
new Sample1(this); // pass the MIDlet to another class.
}
}
Sample1.java
public class Sample1 {
public Sample1(final MIDlet midlet) {
// do something
Command exitCmd = new Command("Exit") {
public void actionPerformed(ActionEvent evt) {
midlat.notifyDestroyed();
}
};
}
}