Android的 - 地点从LocationClient了不支持的速度 [英] Android - Locations got from LocationClient doesn't support speed
问题描述
我是使用新的谷歌LocationClient获取地缘位置。而我需要的速度为每点(位置)。
我现在做的是:
如果(mLocationClient == NULL){
mLocationClient =新LocationClient(这一点,mLocationCallback,mLocationCallback);
mLocationCallback.setLocationClient(mLocationClient);
如果(!(mLocationClient.isConnected()|| mLocationClient.isConnecting())){
mLocationClient.connect();
}
}
在哪里mLocationCallback是一个实例
公共类LocationCallback实现ConnectionCallbacks,
OnConnectionFailedListener,LocationListener的{}
在功能,
@覆盖
公共无效onLocationChanged(位置定位){
如果(位置== NULL){
Log.e(TAG,onLocationChanged:位置==空);
返回;
}
Log.i(TAG,位置@+ location.getLatitude()+,
+ location.getLongitude()+,海拔高度:
+ location.getAltitude()+(+ location.hasAltitude()
+)+速度:+ location.getSpeed()+米/秒(
+ location.hasSpeed()+));
}
}
不过,每次 location.hasSpeed()
给假
。看来,只有GPS提供商给速度。我敢肯定,我的GPS上,但它可能永远不会被使用。
有没有办法强制LocationClient使用GPS提供商?
有没有办法强制LocationClient使用GPS提供商?
没有,因为 LocationClient
的一点是,它混合来自多个源(GPS,WIFI,信号发射塔,传感器等)。数据
如果你需要速度,使用 LocationManager
并用 GPS_PROVIDER
,或其他任何的<$ C $工作C>标准表示,支持速度(例如,伽利略,有一天,也许)。
I'm using the new Google LocationClient to retrieve geo locations. And I need to get speed for each point (location).
What I'm doing now is:
if (mLocationClient == null) {
mLocationClient = new LocationClient(this, mLocationCallback, mLocationCallback);
mLocationCallback.setLocationClient(mLocationClient);
if (!(mLocationClient.isConnected() || mLocationClient.isConnecting())) {
mLocationClient.connect();
}
}
Where mLocationCallback is an instance of
public class LocationCallback implements ConnectionCallbacks,
OnConnectionFailedListener, LocationListener {}
In the function,
@Override
public void onLocationChanged(Location location) {
if (location == null) {
Log.e(TAG, "onLocationChanged: location == null");
return;
}
Log.i(TAG, "Location@ " + location.getLatitude() + ","
+ location.getLongitude() + ", Altitude: "
+ location.getAltitude() + "(" + location.hasAltitude()
+ ")" + " Velocity: " + location.getSpeed() + " m/s("
+ location.hasSpeed() + ")");
}
}
However, everytime location.hasSpeed()
gives false
. It seems that only GPS provider gives speed. I'm sure my GPS is on but it might never be used.
Is there a way to force LocationClient to use GPS provider?
Is there a way to force LocationClient to use GPS provider?
No, because the point of LocationClient
is for it to blend data from multiple sources (GPS, WiFi, cell towers, sensors, etc.).
If you need speed, use LocationManager
and work with the GPS_PROVIDER
, or anything else the Criteria
says supports speed (e.g., Galileo, someday, maybe).
这篇关于Android的 - 地点从LocationClient了不支持的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!