Hi everybody,

I have an issue with the onLocationChanged method on a
LocationListener implementation. It is known that theres's a problem
with this method in 1.5R3 using the emulator. I've searched the
Android groups for workarounds and tried all the workarounds mentioned
in the known issue (http://code.google.com/p/android/issues/detail?
id=1701), mainly (1) remove and add the listener in onLocationChanged
and (2) setting the correct time / time zone.

However, contrary to what is described in the known issue report, I
DON'T get one or two hits on onLocationChanged. I get none. I do get a
couple of hits on onStatusChanged (status=2), once when the listener
is set up in the onCreate method on my activity and once the first GPS
coordinate is sent from DDMS. To me this more or less indicates that
the listener is live and ready, and that a connection between the
emulator and DDMS exists. However, after this, the listener goes
"silent".

I've included the code I've used to test for GPS data, in hope that
someone can point out any flaws. Maybe there's something I've
forgotten to set up? In earlier code I got a LocationProvider without
problems, which should indicate that it should be possible to get GPS
data, no? Furthermore, getLastKnownLocation always returns null...

Thanks in advance!

Kind regards,
Christer


public class GeoStuff extends Activity {
    /** Called when the activity is first created. */
        LocationManager locService = null;
        LocationListener locListener = null;
        //LocationProvider locProvider = null;

        @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final TextView txtView = (TextView)findViewById(R.id.thetext);
        txtView.setText("Here we go..."); //Startup text

        locService = (LocationManager )getSystemService
(Context.LOCATION_SERVICE);

        //locProvider = locService.getProvider
(LocationManager.GPS_PROVIDER);

        Location lastLocation = locService.getLastKnownLocation
(LocationManager.GPS_PROVIDER);

        locListener = new TheLocationListener();

        locService.requestLocationUpdates
(LocationManager.GPS_PROVIDER, 3000, 1, locListener);

    }

        public class TheLocationListener implements LocationListener {
                public void onLocationChanged(Location location) {
                        //Hack from Android forum
                        locService.removeUpdates(locListener);
                locService.requestLocationUpdates
(LocationManager.GPS_PROVIDER, 3000, 1, locListener);
                }

                public void onProviderDisabled(String provider) {
                }

                public void onProviderEnabled(String provider) {
                }

                public void onStatusChanged(String provider, int status, Bundle
extras) {
                        String statusText = "gnu";
                }
        }
}

--~--~---------~--~----~------------~-------~--~----~
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