my dog learned polymorphism
The moose likes Java Micro Edition and the fly likes how to check when Alert is gone? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "how to check when Alert is gone?" Watch "how to check when Alert is gone?" New topic

how to check when Alert is gone?

Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

The result of this is false and in line 3 getCurrent() returns an instance of List instead of an instance of Alert.

How do I check if alert is disposed or not?
Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
The specs say that setCurrent() returns immediately, and the change of screen may happen later, and also calling getCurrent immediately is unlikely to return the screen just set (as is in your case). (See the Javadoc for Display.setCurrent)
For you problem I think you have to add your own command and command listener to the Alert instance, and than you will know when the dismissal happens. For the standard option, with the implicit DISMISS_COMMAND and the implicit listener I don't think you can know that.
Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174


This goes to an unending loop and console keeps writing not yet not yet not yet...
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

I'm confused here. As I recall it, when you display an Alert, it's a synchronous call. As soon as the method terminates, that is itself an indication that the Alert has been dismissed.

To that, you have the option of dispatching to a new form as part of the Alert method call, so that when the Alert ends, the new form takes over. Otherwise execution continues on the current form.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: how to check when Alert is gone?
It's not a secret anymore!