Send a message to it and have it call Looper.quit() in response.

On Thu, Jun 11, 2009 at 6:02 PM, Brad Gies <[email protected]> wrote:

>
>
> Can anyone tell me the proper way to terminate a LooperThread?
>
> Below is the code from the Developer site, but it seems all the methods for
> stopping it have been deprecated.
>
>
>
> class LooperThread extends Thread {
>      public Handler mHandler;
>
>      public void run() {
>          Looper.prepare();
>
>          mHandler = new Handler() {
>              public void handleMessage(Message msg) {
>                  // process incoming messages here
>              }
>          };
>
>          Looper.loop();
>      }
>  }
>
>
> I'm using this in a Service, which creates a main Thread, and the main
> thread checks to see if I need to update my server with GPS coordinates. If
> I do need to send the GPS info, I create a looper thread using the base
> code
> above, and join to it for a maximum of 60 seconds.
>
> I am able to register to receive the GPS information, and set a
> LocationListener inside the Looper Thread, and receive the GPS information.
> When I get the onStatusChanged event with a status of 2 (Available), I want
> to stop/terminate the looperThread, so that I can continue on with the main
> thread, but I don't see any methods left that allow me to terminate it
> properly. The join times out, and the main thread continues, but the
> LooperThread never disappears.
>
> Should I be using another method with SDK 1.5.r2 ?
>
>
>
>
>
> Sincerely,
>
> Brad Gies
>
>
> -----------------------------------------------------------------
> Brad Gies
> 27415 Greenfield Rd, # 2,
> Southfield, MI, USA
> 48076
> www.bgies.com  www.truckerphone.com
> www.EDI-Easy.com  www.EDI-Simple.com
> -----------------------------------------------------------------
>
> Moderation in everything, including abstinence
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to