logo       

Re: Should I do initialing work in midlet constructor?: msg#00210

java.sun.kvm

Subject: Re: Should I do initialing work in midlet constructor?

Just a little thing from the docs, reading this you would think that the
Display.getDisplay() should not be called in the constuctor.

"There is exactly one instance of Display per MIDlet and the application can
get a reference to that instance by calling the getDisplay() method. The
application may call the getDisplay() method from the beginning of the
startApp() call until the destroyApp() call returns. The Display object
returned by all calls to getDisplay() will remain the same during this time.
"


----- Original Message -----
From: "Stefan Haustein" <haustein@xxxxxxxxxxxxxxxxxxxxxxx>
To: <KVM-INTEREST@xxxxxxxxxxxx>
Sent: Friday, September 26, 2003 2:24 PM
Subject: Re: Should I do initialing work in midlet constructor?


> Xu Feng wrote:
> > From Learning wireless Java by Qusay H.Mabmoud, I learned that I should
never call Display.getDisplay() in midlet constructors, because that may
cause errors by application manager.
> > But the startApp() method may be called many times, and that would
consume much time if initialing work is done in the startApp() method.
> >
> > So, how should I do?
>
>
> For example, you could perform the time consuming tasks only if startApp
> was called for the first time...
>
> Display display;
>
> public void startApp() {
> if (display == null) { // not initialized?
> display = Display.getDisplay();
> // further one-time initialization steps..
> }
>
> // show midlet as requested
> }
>
> Cheers,
> Stefan
>
> ---
> http://www.kobjects.org
>
>
===========================================================================
> To unsubscribe, send email to listserv@xxxxxxxxxxxx and include in the
body
> of the message "signoff KVM-INTEREST". For general help, send email to
> listserv@xxxxxxxxxxxx and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to listserv@xxxxxxxxxxxx and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@xxxxxxxxxxxx and include in the body of the message "help".



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise