Android : Android LocationServices getLastLocation returns speed as 0

on Tuesday, March 31, 2015


It gets connected, I can get the latitude and the longitude of the coordinate, but when I do the following code, speed = 0, why can't it take the speed from the location?



@Override
public void onLocationChanged(final Location location) {

Log.i("","geof is s onLocationChanged ENTERED");
if (LocationServices.FusedLocationApi.getLastLocation(mLocationClient) != null) {

locEnd = LocationServices.FusedLocationApi.getLastLocation(mLocationClient);
Log.i("","geof is s speed of locend:" + LocationServices.FusedLocationApi.getLastLocation(mLocationClient).getSpeed());
}
}


This will always be my response:



03-31 17:43:57.227 31463-31463/nl.hgrams.passenger I/﹕ geof is s speed of locend:0.0


And this are my permissions:



<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.LOCATION_HARDWARE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="nl.hgrams.passenger.C2D_MESSAGE" />

0 comments:

Post a Comment