How to call run() of Canvas from MIDlet ?

Discussion in 'Java' started by Boki, Apr 27, 2005.

  1. Boki

    Boki Guest

    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.
     
    Boki, Apr 27, 2005
    #1
    1. Advertising

  2. 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
     
    Fred L. Kleinschmidt, Apr 27, 2005
    #2
    1. Advertising

  3. "Boki" <> 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.
     
    Tor Iver Wilhelmsen, Apr 27, 2005
    #3
  4. Boki

    Boki Guest

    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" <>
    ???????:...
    > "Boki" <> 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, Apr 28, 2005
    #4
  5. 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 <>
    Visit my homepage: http://mcpierce.multiply.com
    "By doubting we come to inquiry, through inquiry truth." - Peter Abelard
     
    Darryl Pierce, Apr 28, 2005
    #5
  6. Boki

    Guest

    Canvas extends Runnable

    :)

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

    Best regards,
    Boki.
     
    , Apr 28, 2005
    #6
  7. "Boki" <> writes:

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


    No, you call myThread.isAlive().
     
    Tor Iver Wilhelmsen, Apr 28, 2005
    #7
  8. Boki

    Boki Guest

    You are the one.

    Best regards,
    Boki.

    "Tor Iver Wilhelmsen" <>
    ???????:...
    > "Boki" <> writes:
    >
    >> =========================
    >> if ( myThread = null ) { ... } ;
    >> =========================
    >> Is that right? or add other variable/flag to detect?

    >
    > No, you call myThread.isAlive().
     
    Boki, Apr 29, 2005
    #8
  9. Boki

    Boki Guest

    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" <>
    ???????:...
    > "Boki" <> writes:
    >
    >> =========================
    >> if ( myThread = null ) { ... } ;
    >> =========================
    >> Is that right? or add other variable/flag to detect?

    >
    > No, you call myThread.isAlive().
     
    Boki, Apr 29, 2005
    #9
  10. 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 <>
    Visit my homepage: http://mcpierce.multiply.com
    "By doubting we come to inquiry, through inquiry truth." - Peter Abelard
     
    Darryl Pierce, Apr 29, 2005
    #10
  11. 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 <>
    Visit my homepage: http://mcpierce.multiply.com
    "By doubting we come to inquiry, through inquiry truth." - Peter Abelard
     
    Darryl Pierce, Apr 29, 2005
    #11
  12. 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 <>
    Visit my homepage: http://mcpierce.multiply.com
    "By doubting we come to inquiry, through inquiry truth." - Peter Abelard
     
    Darryl Pierce, Apr 29, 2005
    #12
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chameleon

    fire midlet run

    Chameleon, Jan 4, 2006, in forum: Java
    Replies:
    1
    Views:
    361
    Darryl L. Pierce
    Jan 4, 2006
  2. Askari
    Replies:
    2
    Views:
    735
    Askari
    Aug 30, 2004
  3. PhilC
    Replies:
    2
    Views:
    923
    PhilC
    Oct 25, 2004
  4. Arlenx
    Replies:
    0
    Views:
    331
    Arlenx
    May 3, 2009
  5. Replies:
    10
    Views:
    296
    Rick Johnson
    Mar 15, 2013
Loading...

Share This Page