Android LocationServices getLastLocation returns 速度为 0
Android LocationServices getLastLocation returns speed as 0
连接上了,我可以得到坐标的经纬度,但是当我做下面的代码时,speed = 0,为什么不能从位置上取速度?
@Override
public void onLocationChanged(final Location location) {
Log.i("","geof is s onLocationChanged ENTERED");
if (LocationServices.FusedLocationApi.getLastLocation(mLocationClient) != null) {
locEnd = location;
Log.i("","geof is s speed of locend:" + location.getSpeed());
}
}
这将永远是我的回应:
03-31 17:43:57.227 31463-31463/nl.hgrams.passenger I/﹕ geof is s speed of locend:0.0
这是我的权限:
<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" />
我不确定这是否是您要查找的内容:
https://developer.android.com/reference/android/location/Location.html#getSpeed()
但 getSpeed 的 "normal" 默认为 return 0.0,因为您的位置没有速度(如文档中所示)。
连接上了,我可以得到坐标的经纬度,但是当我做下面的代码时,speed = 0,为什么不能从位置上取速度?
@Override
public void onLocationChanged(final Location location) {
Log.i("","geof is s onLocationChanged ENTERED");
if (LocationServices.FusedLocationApi.getLastLocation(mLocationClient) != null) {
locEnd = location;
Log.i("","geof is s speed of locend:" + location.getSpeed());
}
}
这将永远是我的回应:
03-31 17:43:57.227 31463-31463/nl.hgrams.passenger I/﹕ geof is s speed of locend:0.0
这是我的权限:
<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" />
我不确定这是否是您要查找的内容: https://developer.android.com/reference/android/location/Location.html#getSpeed()
但 getSpeed 的 "normal" 默认为 return 0.0,因为您的位置没有速度(如文档中所示)。