Android 从LocationManager取消订阅LocationListener

Android 从LocationManager取消订阅LocationListener,android,locationmanager,locationlistener,Android,Locationmanager,Locationlistener,如何取消订阅从LocationManager接收更新的LocationListener 下面是我如何设置它的 mLocationManager = (LocationManager)this.getSystemService(LOCATION_SERVICE); mListener = new LocationListener() { public void onLocationChanged(Location location) { Log.i("LocationLis

如何取消订阅从
LocationManager
接收更新的
LocationListener

下面是我如何设置它的

mLocationManager = (LocationManager)this.getSystemService(LOCATION_SERVICE);
mListener = new LocationListener() {
    public void onLocationChanged(Location location) {
        Log.i("LocationListener", "Logging Change");
    }

}

mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                5000, 1, mListener);
退出创建
LocationListener
的视图后,我仍然在LogCat窗口中收到日志消息

我明白这是因为我孤立了侦听器,但我在
LocationListener
上看不到任何销毁方法,也看不到
LocationManager
对象上的任何“删除侦听器”样式的方法。

调用LocationManager,传递您的位置侦听器。

我认为应该有所帮助

mLocationManager.removeUpdates(mListener)

如果您没有将侦听器存储为成员,有没有办法做到这一点?如果您没有将侦听器存储为成员,有没有办法做到这一点?
mLocationManager.removeUpdates(mListener);