Display from non-MIDlet class?

T

thonbrocket

I havel a method in my main MIDlet that flashes up a message as an
Alert:

public void doAlert(String sAlertText) {
Alert alSending;
alSending = new Alert(null, sAlertText, null, AlertType.INFO);
alSending.setTimeout(3000);
m_display.setCurrent(alSending);
}


m_display is declared and instantiated in the main MIDlet:

public class Boss extends MIDlet implements CommandListener {

public static Display m_display;

public Boss() { /** Constructor*/
m_display = Display.getDisplay( this );
}
.............
}



Now when I try to call this from another class:

new Boss().doAlert("Eat lead, Bambi!");


I get: "SecurityException: Application not authorized to access the
restricted API". The same happens if I try to use a reference to a
MIDlet, rather than to a Display. Apparently, you can't instantiate a
MIDlet from with another MIDlet / class.

So, how do you obtain a reference to the currently-running MIDlet or
its Display from a different class?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,293
Latest member
Hue Tran

Latest Threads

Top