Android Google glass-GDK应用程序getSpeed()返回0.0

Android Google glass-GDK应用程序getSpeed()返回0.0,android,gps,google-glass,google-gdk,Android,Gps,Google Glass,Google Gdk,我试图在google glass live卡上显示用户的速度。 我可以获取纬度和经度,但getSpeed()始终返回0.0。我已经检查了类似的问题,但没有帮助 这是我的密码 Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); LocationManager mLocationManager = (LocationManager) getS

我试图在google glass live卡上显示用户的速度。 我可以获取纬度和经度,但getSpeed()始终返回0.0。我已经检查了类似的问题,但没有帮助

这是我的密码

        Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        LocationManager mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
        String provider = mLocationManager.getBestProvider(criteria, true);
        boolean isEnabled = mLocationManager.isProviderEnabled(provider);
        if (isEnabled) {
        // Define a listener that responds to location updates
        LocationListener locationListener = new LocationListener() {
        @Override
        public void onLocationChanged(Location location) {
        // Called when a new location is found by the network location provider.
        if (location != null) {
        Geocoder geocoder = new Geocoder(Start_service.this.getBaseContext(), Locale.getDefault());
        // lat,lng, your current location
        List<Address> addresses = null;
        try {
            lati= location.getLatitude();
            longi=location.getLongitude();
            speed=location.getSpeed();
        addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
        }
        catch (IOException e) {
        System.out.println(e);
        e.printStackTrace();
        }
标准=新标准();
标准.设定准确度(标准.准确度/精细度);
LocationManager MLLocationManager=(LocationManager)getSystemService(LOCATION\u服务);
字符串提供程序=mLocationManager.getBestProvider(条件为true);
布尔值isEnabled=mlLocationManager.isProviderEnabled(提供程序);
如果(已启用){
//定义响应位置更新的侦听器
LocationListener LocationListener=新LocationListener(){
@凌驾
已更改位置上的公共无效(位置){
//当网络位置提供程序找到新位置时调用。
如果(位置!=null){
Geocoder Geocoder=新的Geocoder(Start_service.this.getBaseContext(),Locale.getDefault());
//lat,lng,你现在的位置
列表地址=空;
试一试{
lati=location.getLatitude();
longi=location.getLongitude();
速度=位置。getSpeed();
addresses=geocoder.getFromLocation(location.getLatitude(),location.getLatitude(),1);
}
捕获(IOE异常){
系统输出打印ln(e);
e、 printStackTrace();
}
您只能从调用setSpeed的提供程序获取速度。您可以设置Criteria变量以指示您需要速度值

Criteria criteria = new Criteria();
criteria.setSpeedRequired(true);
<>或者你可以考虑自己计算一下。看。< /P>
另外,使用hasSpeed()检查速度是否可用。

即使我设置了条件。.速度返回0。.有什么线索吗?我不确定。可能是GDK的错误。它仍然是测试版,请耐心等待。