androidthings / drivers-samples

Peripheral driver samples
Apache License 2.0
153 stars 57 forks source link

GPS Location Speed always null #7

Closed ckoessler closed 6 years ago

ckoessler commented 7 years ago

I am trying to get the speed from the Location object that I get from my LocationListener, the object never has speed.

private LocationListener mLocationListener = new LocationListener() {

        @Override
        public void onLocationChanged(Location location) {
            if(location.hasSpeed()) {
                 Log.d(TAG, "We got speed!!!");
            }
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
        }

        @Override
        public void onProviderEnabled(String provider) {
        }

        @Override
        public void onProviderDisabled(String provider) {
        }
    };

My Log never get hit although the lat long are correct.

I put some breakpoints in NmeaGpsDriver#onGpsSpeedUpdate and in GpsDriver#reportLocation and I see the speed having the correct value there.

I tried to log while having the device moving at 30mph, no speed at all from the LocationListener.

devunwired commented 6 years ago

Apologies for not responding to this sooner. This was a limitation of the GpsDriver API that was exposed during developer preview. The GnssDriver API available as of Android Things 1.0 exposes all the fields of a location object.