How to call run() of Canvas from MIDlet ?

B

Boki

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.
 
F

Fred L. Kleinschmidt

Boki said:
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.
 
T

Tor Iver Wilhelmsen

Boki said:
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.
 
B

Boki

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.
 
D

Darryl Pierce

Boki said:
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...
 
B

bokiteam

Canvas extends Runnable

:)

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

Best regards,
Boki.
 
T

Tor Iver Wilhelmsen

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

No, you call myThread.isAlive().
 
B

Boki

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.
 
D

Darryl Pierce

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...
 
D

Darryl Pierce

Boki said:
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.
 
D

Darryl Pierce

Boki said:
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.
 

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,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top