Android Uygulamamda bir sorunum var.Android LocationManager her zaman aynı eski konumu döndürür
onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
requestPermission();
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 0, this);
// Define the criteria how to select the location provider -> use
// default
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
onLocationChanged(location);
}
}
}
onLocationChanged:
@Override
public void onLocationChanged(Location location) {
if (mMap != null) {
setMoveToLocation(location, mMap.getCameraPosition().zoom);
}
}
Ve
private void setMoveToLocation(Location location, float zoom) {
// Add a marker at given location and move the camera
int lat = (int) (location.getLatitude());
int lng = (int) (location.getLongitude());
Log.i("Location", "Lat: " + lat + ", Long: " + lng + " Time: " + location.getTime());
LatLng pos = new LatLng(lat, lng);
mMap.addMarker(new MarkerOptions().position(pos).title("Your position"));
Log.i("Zoom", "Zoom: " + zoom);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pos, zoom));
}
çıkışı Bkz setMoveToLocation: kod aşağıdaki konum güncellemeleri almak istiyor ve yazdı Log output
Her zaman aynı yanlış konum, 51,7 konumunda değilim! GPS kesinlikle kesildi, ilgili bildirimi ve Google Haritalar gibi diğer uygulamaları aldım veya İşte düzgün çalışıyoruz. Android 6.0 ile Huawei Honor 7 kullanıyorum.
Herhangi bir fikrin var mı? peşin
sayesinde Plebo
Ah adam , çok teşekkür ederim!! Gerçekten çok aptalım: D – Plebo