0
我試圖在谷歌玻璃活卡上顯示用戶的速度。 我能夠獲得經度和緯度,但getSpeed()總是返回0.0。我已經檢查過類似的問題,但沒有幫助。Google glass-GDK app 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();
}
即使我設置標準..速度返回0 ..任何線索? – 2014-10-30 11:05:46
好吧,我不確定。可能是GDK的錯誤。它仍然是測試版,請耐心等待。 – pt2121 2014-10-31 03:08:34