J2ME, handling the red END key.

Started by
2 comments, last by Sneftel 19 years, 7 months ago
During any point in a MIDlet's life-time, is there any way to properly handle the red key (END key) so that the application/game does not terminate? Thanks.
Advertisement
Normally, no. A few phones will allow you to ignore the red END button by passing in "true" to the "unconditional" parameter of destroyApp. If it does this, you can throw a MIDletStateChangeException to refuse to terminate. Most phones, however, don't give you the choice.
Nokia Series 60 phones do not kill your app when you hit the END key, but instead put them into the background. But they apparently don't send pauseApp() either, because of Nokia's broken implementation :) But you *will* receive showNotify() and hideNotify() as appropriate.

And wouldn't that be a *false* 'unconditional' value which allows you to escape? (Note that this is being passed in by the phone, not from your code.)

And you can throw the exception anyway, the compiler can't do anything to stop you. The phone will presumably ignore it and quit anyway, though.

This is one of the many things I find silly about the whole MIDlet class design: I can't imagine why you'd *ever* check the 'unconditional' parameter, given that the caller is responsible for handling any exception anyway. Hell, they even made MSCE *checked*!

(Or does the preverifier maybe do something weird here? o_O)
Quote:Original post by Zahlman
And wouldn't that be a *false* 'unconditional' value which allows you to escape? (Note that this is being passed in by the phone, not from your code.)
Er, yeah. *smacks self*

This topic is closed to new replies.

Advertisement