I'm trying to get a GPS speed from my Glass (obviously the GPS signal would be coming through the phone). Using the following code, I was able to get location data from the network, but the speed always prints as 0.0. Using the GPS, I get an error that I've provided "an illegal argument" on the last line of the code below. What is the best way to get an accurate and consistent speed reading? Thank you in advance!
LocationManager locationManager = (LocationManager) this
.getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
location.getLatitude();
System.out.println("Location changed. Speed is: " + location.getSpeed() + " Lat: " + location.getLatitude() + " Lon: " + location.getLongitude());
}
public void onStatusChanged(String provider, int status,
Bundle extras) {
}
public void onProviderEnabled(String provider) {
}
public void onProviderDisabled(String provider) {
}
};
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0,0, locationListener);