worked like a charm, thanks.
jim

On Feb 22, 10:03 am, Mark Murphy <[email protected]> wrote:
> cellurl wrote:
> > I got it to work in an entirely different Activity, but this one uses
> > a thread, so perhaps that's a clue.
>
> <snip>
>
> >         @Override
> >         public void run() {
>
> >           Looper.prepare();
>
> It is quite stunning how much Android code you can write without needing
> a custom Looper. My advice has always been, and will remain, that if you
> feel you need a Looper, start by looking for other implementation
> patterns, then and only then actually put in the Looper.
>
> >           final LocationListener locationListener= new
> > LocationListener() {
> >               public void onLocationChanged(Location newloc) {
> >                        Log.d("TAG","NEVER GETS HERE");
> >               }
> >               public void onProviderDisabled(String provider) {}
> >               public void onProviderEnabled(String provider) {}
> >               public void onStatusChanged(String provider, int status,
> >                            Bundle extras) {}
> >           };
>
> You are declaring your LocationListener inside your Runnable. That is
> very scary. Try declaring it on your Activity or Service or something.
>
> Even better, there is absolutely no reason to be registering for
> location updates in a background thread. Register for the location
> updates on your main application thread. If you need to do the work
> triggered by the location update on a background thread, deal with it
> only at that point (e.g., by an AsyncTask). You can see an example of
> that pattern here:
>
> http://github.com/commonsguy/cw-android/tree/master/Service/WeatherPlus/
>
> >           lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
> > (float) 0.001, locationListener);
>
> >           while (true)
> >           {
> >              }
>
> Never never never never never never never never never never never never
> never never never never never never never never never never never never
> never never never never never never never never never never never never
> never never never never never never never never never never never never
> never do this.
>
> You went and declared a Looper, then decided that you're not actually
> going to use the Looper, because you never give the Looper a chance to
> do anything. So even if your LocationListener is properly registered, it
> will never get control, because your thread is tied up in this busy loop.
>
> Furthermore, a tight busy loop like that is going to chew up the CPU
> enough that it will make anything else difficult to run.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Training in US: 26-30 April 2010:http://onlc.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to