Я пытаюсь отобразить скорость пользователя на живой карточке Google. Я могу получить широту и долготу, но getSpeed () всегда возвращает 0.0. Я проверил подобные вопросы по SO, но без помощи.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..Любые подсказки? –
ну, я не уверен. вероятно, ошибка GDK. Это все еще бета, поэтому, пожалуйста, будьте терпеливы. – pt2121