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.
Asked
Active
Viewed 772 times
1 Answers
2
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();
}
};
}
}

bharath
- 14,283
- 16
- 57
- 95
-
Thanks so much. It worked. I think though there's a typo on the line: midlat.notifyDestroyed(); It is a reference to the final MIDlet 'midlet' parameter in the constructor. destroyApp(true) did not work: There's an access privilege error. So I used notifyDestroyed(); Thanks – Peter Jul 21 '11 at 21:01