我的 Activity 如下实现 LocationListener
public class LoginActivity extends Activity implements LocationListener {}
我的 LocationManager 如下所示
mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, MINIMUM_TIME_BETWEEN_UPDATES, MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, this);
我可以使用 about 方法获取当前 GPS 位置。
现在我需要在 Activity 关闭时释放 GPS。
所以我的 onPause 方法如下所示。
@Override
protected void onPause() {
mlocManager.removeUpdates(this);
//System.exit(0);
super.onPause();
}
但这并没有释放 GPS。有人可以帮我吗。提前致谢。
最佳答案
我可能是有另一个位置监听器调用了 requestLocationUpdates()
。
如果不是,您应该在 finish()
、onStop()
和 onDestroy()
中调用 removeUpdates()
> 只是为了确定。这应该可以解决问题。
关于安卓:释放GPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8222456/