0
Ich möchte die Position pro 10 Millisekunde, aber meine Standortänderung in etwa 30 Sekunden oder 40 Sekunden. Wo ist meine Schuld? Hilft mir jemand? Ich benutze diesen Codeblock. Ich benutzte es auch, aber ich erhalte einige Ausgabe http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/Empfindlichkeit Android Location Sensor
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override
protected void onDestroy() {
super.onDestroy();
mGoogleApiClient.disconnect();
}
synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}
@Override
public void onConnected(Bundle bundle) {
mLocationRequest = LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(1); // Update location every second
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
mGoogleApiClient);
if (mLastLocation != null) {
lat = String.valueOf(mLastLocation.getLatitude());
lon = String.valueOf(mLastLocation.getLongitude());
}
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onLocationChanged(Location location) {
mLastLocation = location;
Toast.makeText(MainActivity.this, location.getLatitude()+"+-+"+location.getLongitude(), Toast.LENGTH_SHORT).show();
updateUI();
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
buildGoogleApiClient();
}
void updateUI() {
Log.e("Updated",lat+"---"+lon);
}
Android Version 6.0.1
es nicht funktioniert:/again i Standort erhalten pro 40- 50 sek. –