How can I stop getActiveScreen to throw ClassCastException?

If the current field is an instance of the screen, I can do the following:

CoffeeCard cCard = (CoffeeCard) MyClient.getUiApplication().getActiveScreen();

However, if a Menu or a dialog box is open, I get a ClassCastException in the statement foregoing, which makes sense.

In addition to checking the returned value of getActiveScreen with the instanceof keyword, is there a better way to check if the active screen is a screen?

Thank you.

What is the problem with instanceof?

for specific classes, you can use a model of the Inspector, but not for this.

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for