Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy getSpeed() always return 0 on android
    primarykey
    data
    text
    <p>I need to get the speed and heading from the gps. However the only number i have from <code>location.getSpeed()</code> is 0 or sometimes not available. my code: </p> <pre><code> String provider = initLocManager(); if (provider == null) return false; LocationListener locListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location, interval, startId); Log.i(getString(R.string.logging_tag), "speed =" + location.getSpeed()); } public void onProviderDisabled(String provider){ updateWithNewLocation(null, interval, startId); } public void onProviderEnabled(String provider) {} public void onStatusChanged(String provider, int status, Bundle extras) {} }; _locManager.requestLocationUpdates(provider, interval, DEFAULT_GPS_MIN_DISTANCE, locListener); private String initLocManager() { String context = Context.LOCATION_SERVICE; _locManager = (LocationManager) getSystemService(context); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(true); criteria.setSpeedRequired(true); criteria.setCostAllowed(true); //criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = _locManager.getBestProvider(criteria, true); if (provider == null || provider.equals("")) { displayGPSNotEnabledWarning(this); return null; } return provider; } </code></pre> <p>I tried to play the Criteria with but no success. Does anyone have an idea what is the problem?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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