tags:

views:

852

answers:

3

After launching listener by the following code is working fine.

LocationManager locationManager =(LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(
                    LocationManager.GPS_PROVIDER, WLConstants.DELAY_HOUR, gpsl
                            .getMinDistance(), gpsl);

After some time i stop the listener by the following code

locationManager.removeUpdates(this);

but problem is it still searching my gps any solution ??? how to stop gps ?

A: 

My listener implemention

public class GPSLocationListener extends Activity implements LocationListener {

    @Override
        public void onLocationChanged(Location location) {
//code here
    }

    }

when i try to remove listener using follwing code compile time error.

locationManager.removeGpsStatusListener(GPSLocationListener )
Faisal khan
You need to use the *instance* name rather than the *class* name when removing the listener.In your original question, your listener is a variable called `gpsl`. Presumably, this is a member variable in your class. If not, make it a member variable instead of local to that method. Then you can pass `gpsl` when you call `removeGpsStatusListener`.
Christopher
+3  A: 

You need to pass the same object implementing LocationListener that you requested location updates for to the locationManager.removeUpdates() method.

So in unless this and gpsl are one and the same, you should call:

locationManager.removeUpdates(gpsl);
Jeff Gilfelt
A: 

You have to pass the instance to your GPSLocationListener go the removeGpsStatusListener method and not the class name.

Stelian Iancu