How do you test GPS applications in Android? Can we test it using the Android emulator?
+4
A:
Yes.
If you develop using the Eclipse ADT plugin, open the DDMS perspective after launching the emulator and look for the Emulator Control view. There is a location controls section that allows you to send fixed latitude and longitude coordinates, or GPX (GPS Exchange Format) or KML (Keyhole Markup Language) files if you want to send multiple coordinates at regular intervals (to simulate traveling a specific route).
Alternatively, you can simply telnet to the emulator and use the geo command from the command line, which supports fixed latitude and longitude coordinates as well as NMEA data sentences:
telnet localhost 5554
geo fix -82.411629 28.054553
geo nmea $GPGGA,001431.092,0118.2653,N,10351.1359,E,0,00,,-19.6,M,4.1,M,,0000*5B
Jeff Gilfelt
2009-12-29 12:48:52
A:
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:
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
Mallox
2010-10-15 09:10:49