How do you test GPS applications in Android? Can we test it using the Android emulator?
Maybe you want to a use a Unit test, so you can try this:
public class GPSPollingServiceTest extends AndroidTestCase {
private LocationManager locationManager;
public void testGPS() {
LocationManager locationManager = (LocationManager) this.getContext().getSystemService(Context.LOCATION_SERVICE);
locationManager.addTestProvider("Test", false, false, false, false, false, false, false, Criteria.POWER_LOW, Criteria.ACCURACY_FINE);
locationManager.setTestProviderEnabled("Test", true);
// Set up your test
Location location = new Location("Test");
location.setLatitude(10.0);
location.setLongitude(20.0);
locationManager.setTestProviderLocation("Test", location);
// Check if your listener reacted the right way
locationManager.removeTestProvider("Test");
}
}
For this to work you also need a required permission to the AndroidManifest.xml: