【发布时间】:2018-09-19 00:05:18
【问题描述】:
我想知道如何获取我最后的已知位置(GPS 或提供的网络)。我问这个是因为我知道如何获取我的位置,但它会定期更新,我只想要一次,不再需要了。
这是我的实际代码:
@Override
public void onLocationChanged(Location location) {
Toast.makeText(getContext(),"Cambio posicion "+location.getProvider(),Toast.LENGTH_SHORT).show();
this.marca.title("Mi ubicacion");
this.marca.position(new LatLng(location.getLatitude(),location.getLongitude()));
mMap.addMarker(this.marca);
this.camara = CameraPosition.builder()
.bearing(0)
.zoom(15)
.target(new LatLng(location.getLatitude(),location.getLongitude()))
.tilt(30)
.build();
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(this.camara));
}
我正在使用 LocationManager。感谢您的帮助。
【问题讨论】:
标签: android google-maps android-studio android-maps