Switch
Switch

Reputation: 15443

J2ME notifyDestroyed()

notifyDestroyed() method is called by the MIDlet to notify AMS that it want to go to the Destroyed State. once this notification is received by the AMS, it will asssume that the MIDlet has already done all the resources clearing process before calling notifyDestroyed() method.

Therefore is it going to kill the MIDlet rather than calling destroyApp() method.

Upvotes: 2

Views: 2562

Answers (2)

michael aubert
michael aubert

Reputation: 6826

The AMS will definitely not call destroyApp() after notifyDestroyed() has been called.

An incorrect AMS that would do this could end up in a stack overflow situation when running a correct MIDlet.

Upvotes: 1

Sean A.O. Harney
Sean A.O. Harney

Reputation: 24497

It seems like it is best practice to call destroyApp() before notifyDestroyed().

try {
// Call destroyApp to release resources
destroyApp(false);
// Arrange for the MIDlet to be destroyed
notifyDestroyed();
} catch (MIDletStateChangeException ex) {
// MIDlet does not want to close
 }

Upvotes: 1

Related Questions