2014-09-05 2 views
0

Google 유리 라이브 카드에서 사용자의 속도를 표시하려고합니다. 위도와 경도를 얻을 수 있지만 getSpeed ​​()는 항상 0.0을 반환합니다. 나는 SO에 관해서 비슷한 질문을했지만 아무런 도움이되지 않았다.Google Glass-GDK 앱 getSpeed ​​()가 0.0을 반환합니다.

여기에만 setSpeed를 호출하는 공급자로부터 getSpeed ​​수 있습니다 내 코드

 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(); 
     } 

답변

1

Location providers don't guarantee to provide the speed value.입니다. Criteria 변수를 설정하여 속도 값이 필요함을 나타낼 수 있습니다.

Criteria criteria = new Criteria(); 
criteria.setSpeedRequired(true); 

또는 직접 계산하는 것이 좋습니다. why getSpeed() always return 0 on android을 참조하십시오.

또한 hasSpeed ​​()를 사용하여 속도를 사용할 수 있는지 확인하십시오.

+0

기준을 설정하더라도 속도가 0을 반환합니다. 단서가 있습니까? –

+1

음, 잘 모르겠습니다. 아마도 GDK의 버그 일 것입니다. 아직 베타 버전이므로 잠시 기다려주십시오. – pt2121

관련 문제