Note that there are some explanatory texts on larger screens.

plurals
  1. POLocationRequest in Google Play Services isn't updating for interval set as less than 1 second.
    primarykey
    data
    text
    <p>I'm developing an android app in which I need to show location updates with some 30-40 updates per second. I'm using the <a href="http://developer.android.com/google/play-services/location.html" rel="nofollow">Location APIs of Google Play Services</a>, introduced in Google I/O 2013. It uses a fused location provider (making use of accelerometers and other sensors along with GPS) for more accurate &amp; efficient location tracking.</p> <p>Here's my code:</p> <pre><code>protected void startLocationTracking() { if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(this)) { mLocationClient = new LocationClient(this, mConnectionCallbacks, mConnectionFailedListener); mLocationClient.connect(); } } private ConnectionCallbacks mConnectionCallbacks = new ConnectionCallbacks() { @Override public void onDisconnected() { } @Override public void onConnected(Bundle arg0) { LocationRequest locationRequest = LocationRequest.create(); locationRequest.setFastestInterval(0); locationRequest.setInterval(0).setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationClient.requestLocationUpdates(locationRequest, mLocationListener); } }; private OnConnectionFailedListener mConnectionFailedListener = new OnConnectionFailedListener() { @Override public void onConnectionFailed(ConnectionResult arg0) { Log.e(TAG, "ConnectionFailed"); } }; private LocationListener mLocationListener = new LocationListener() { private long mLastEventTime = 0; @Override public void onLocationChanged(Location location) { double delayBtnEvents = (System.nanoTime()- mLastEventTime )/(1000000000.0); mLastEventTime = System.nanoTime(); //Sampling rate is the frequency at which updates are received String samplingRate = (new DecimalFormat("0.0000").format(1/delayBtnEvents)); float speed = (float) (location.getSpeed() * 3.6); // Converting m/s to Km/hr tv.setText(speed + " kmph" + ", " + samplingRate + " Hz"); //Updating UI } }; </code></pre> <p><strong>I have set priority as PRIORITY_HIGH_ACCURACY and the interval &amp; the fastest interval as 0 milliseconds here. But I still receive updates on every 1 second only.</strong> </p> <blockquote> <p>This pretty much looks like the update frequency of the GPS sensor of any Android phone. But I was expecting more as this is using a Fusion Sensor (which includes accelerometer). Accelerometer being part of fusion sensor should yield higher frequency than this.</p> </blockquote> <p>I have tried other values for the interval, but could not get updates for less than 1 sec interval. Also ACCESS_FINE_LOCATION is used for permission in manifest.</p> <p>Am I missing something here? Is their any other approach to accomplish this? I'll be grateful for any help to solve this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload