I\'m trying to get this bit of code to work:
Testing GPS in Android
The problem is, when I run the test, onLocationChanged() is never called:
This is what worked for me
locationManager.addTestProvider(mocLocationProvider, false, false,
false, false, true, true, true, 0, 5);
locationManager.setTestProviderEnabled(mocLocationProvider, true);
.
Location mockLocation = new Location(mocLocationProvider); // a string
mockLocation.setLatitude(location.getLatitude()); // double
mockLocation.setLongitude(location.getLongitude());
mockLocation.setAltitude(location.getAltitude());
mockLocation.setTime(System.currentTimeMillis());
locationManager.setTestProviderLocation( mocLocationProvider, mockLocation);
.
Also in the android phone settings make sure you have the "Allow mock locations" checkbox ticked