如何将LocationManager更改为只获取一个位置?应用程序会不断更新位置。
public void onClick(View view)
//this make the app keep update
locationManager.requestLocationUpdates("gps", 0, 0, listener);发布于 2018-11-03 02:21:50
第一种方法是使用locationManager.requestSingleUpdate()而不是locationManager.requestLocationUpdates()
或
第二种解决方案是在收到第一个更新后立即注销监听程序,如下所示:
@Override
public void onLocationChanged(Location location) {
locationManager.removeUpdates(this);
// do something with the received location
}https://stackoverflow.com/questions/53123279
复制相似问题