0

10 밀리 초당 위치를 가져오고 싶지만 내 위치는 약 30 초 또는 40 초로 변경됩니다. 내 잘못은 어디에 있습니까? 아무도 날 도와주지? 이 코드 블록을 사용하고 있습니다. 나도 그것을 사용하지만 난 http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/감도 Android 위치 센서

@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); 
} 

안드로이드 버전 6.0.1

답변

1
당신은 다음과 같이 할 수

몇 가지 문제를 얻을 :

mLocationRequest.setInterval(3000); 
mLocationRequest.setFastestInterval(1000); // For 1 Second = 1000 millis 
+0

이 나던 일이 :/다시 내가 당 위치를 얻을 수 40 50 초. –