How to call run() of Canvas from MIDlet ?  
Author Message
Boki





PostPosted: 2005-4-28 0:04:00 Top

java-programmer, How to call run() of Canvas from MIDlet ? Hi All,
I want to restart the run() of Canvas from the call of MIDlet,
how to do it ?

Thank you very much.

Best regards
Boki.


 
Fred L. Kleinschmidt





PostPosted: 2005-4-28 1:30:00 Top

java-programmer >> How to call run() of Canvas from MIDlet ?

Boki wrote:
>
> Hi All,
> I want to restart the run() of Canvas from the call of MIDlet,
> how to do it ?
>
> Thank you very much.
>
> Best regards
> Boki.

I do not understand what you mean. Canvas does not hava a run() method.

--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225
 
Tor Iver Wilhelmsen





PostPosted: 2005-4-28 1:47:00 Top

java-programmer >> How to call run() of Canvas from MIDlet ? "Boki" <email***@***.com> writes:

> I want to restart the run() of Canvas from the call of
> MIDlet, how to do it ?

Well, canvases usually don't have such a method; most likely your
class implements Runnable, and uses a Thread to do it.

Solution: Move the code creating and start() ing the thread somewhere
where you can start a new one. Make sure you check that the old thread
is dead (has exited) first.
 
 
Boki





PostPosted: 2005-4-28 14:16:00 Top

java-programmer >> How to call run() of Canvas from MIDlet ? Hi
Thank you very much for your reply.

If I want to check the thread is dead:

=========================
if ( myThread = null ) { ... } ;
=========================
Is that right? or add other variable/flag to detect?

Thank you very much for your help.

Best regards,
Boki.


"Tor Iver Wilhelmsen" <email***@***.com>
???????:email***@***.com...
> "Boki" <email***@***.com> writes:
>
>> I want to restart the run() of Canvas from the call of
>> MIDlet, how to do it ?
>
> Well, canvases usually don't have such a method; most likely your
> class implements Runnable, and uses a Thread to do it.
>
> Solution: Move the code creating and start() ing the thread somewhere
> where you can start a new one. Make sure you check that the old thread
> is dead (has exited) first.


 
 
Darryl Pierce





PostPosted: 2005-4-28 19:00:00 Top

java-programmer >> How to call run() of Canvas from MIDlet ? Boki wrote:
> I want to restart the run() of Canvas from the call of MIDlet,
> how to do it ?

Canvas doesn't *have* a run() method. If you're talking about restarting
a Thread, you would create a *new* Thread object...

--
Darryl L. Pierce <email***@***.com>
Visit my homepage: http://mcpierce.multiply.com
"By doubting we come to inquiry, through inquiry truth." - Peter Abelard
 
 
bokiteam





PostPosted: 2005-4-28 20:23:00 Top

java-programmer >> How to call run() of Canvas from MIDlet ? Canvas extends Runnable

:)

How about I new a thread but the same name, Does J2ME will delete the
prvious one automatically?

Best regards,
Boki.

 
 
Tor Iver Wilhelmsen





PostPosted: 2005-4-29 1:43:00 Top

java-programmer >> How to call run() of Canvas from MIDlet ? "Boki" <email***@***.com> writes:

> =========================
> if ( myThread = null ) { ... } ;
> =========================
> Is that right? or add other variable/flag to detect?

No, you call myThread.isAlive().
 
 
Boki





PostPosted: 2005-4-29 9:16:00 Top

java-programmer >> How to call run() of Canvas from MIDlet ? You are the one.

Best regards,
Boki.

"Tor Iver Wilhelmsen" <email***@***.com>
???????:email***@***.com...
> "Boki" <email***@***.com> writes:
>
>> =========================
>> if ( myThread = null ) { ... } ;
>> =========================
>> Is that right? or add other variable/flag to detect?
>
> No, you call myThread.isAlive().


 
 
Boki





PostPosted: 2005-4-29 10:00:00 Top

java-programmer >> How to call run() of Canvas from MIDlet ? Hi, I need you help.

I test keyPressed() that can't report soft keys on S700i, K700i, K750i...

I believe there is something wrong, but what should I do more?

I only get the value that keyPressed() evet bring to me...


and there is nothing happen when I press soft keys...


Thank you very much.

Best regards,
Boki.

"Tor Iver Wilhelmsen" <email***@***.com>
???????:email***@***.com...
> "Boki" <email***@***.com> writes:
>
>> =========================
>> if ( myThread = null ) { ... } ;
>> =========================
>> Is that right? or add other variable/flag to detect?
>
> No, you call myThread.isAlive().


 
 
Darryl Pierce





PostPosted: 2005-4-29 18:23:00 Top

java-programmer >> How to call run() of Canvas from MIDlet ? email***@***.com wrote:
> Canvas extends Runnable
>
> :)
>
> How about I new a thread but the same name, Does J2ME will delete the
> prvious one automatically?

If you assign a new instance of Thread to an existing Thread reference,
the old one will be garbage collected. However, you *must* end that
other thread's operation so that it's not consuming CPU resources...

--
Darryl L. Pierce <email***@***.com>
Visit my homepage: http://mcpierce.multiply.com
"By doubting we come to inquiry, through inquiry truth." - Peter Abelard
 
 
Darryl Pierce





PostPosted: 2005-4-29 18:24:00 Top

java-programmer >> How to call run() of Canvas from MIDlet ? Boki wrote:
> If I want to check the thread is dead:
>
> =========================
> if ( myThread = null ) { ... } ;
> =========================
> Is that right? or add other variable/flag to detect?

No, the reference to the Thread will not become magically null when the
Thread stops. You check the Thread.isAlive() API for the Thread's active
state.

--
Darryl L. Pierce <email***@***.com>
Visit my homepage: http://mcpierce.multiply.com
"By doubting we come to inquiry, through inquiry truth." - Peter Abelard
 
 
Darryl Pierce





PostPosted: 2005-4-29 18:26:00 Top

java-programmer >> How to call run() of Canvas from MIDlet ? Boki wrote:
> I test keyPressed() that can't report soft keys on S700i, K700i, K750i...

Canvas.keyPressed() is not required to report all keys, including the
soft keys and any special keys on the handset. Only the UTI-9 keys are
required to be reported. Since those keys are special purpose, and since
the soft keys are already covered by the Command class, the OEM doesn't
have to report them. If the phone's not reporting them, it's not a bug
nor a defect: it's just inconvenient.

--
Darryl L. Pierce <email***@***.com>
Visit my homepage: http://mcpierce.multiply.com
"By doubting we come to inquiry, through inquiry truth." - Peter Abelard