Automatically setting the GPS location in Android emulator
In Eclipse the emulator’s GPS coordinates can be set by changing to DDMS view (Window->Open Perspective->DDMS), then setting the location in the Location Controls.
As the emulator is listening on localhost:5554 for a telnet-like connection, you can set the coordinates manually using the simple telnet application:
telnet localhost 5554 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Android Console: type 'help' for a list of commands OK geo fix 151.195733 -33.866745
Watch out for the latitude-longitude order, as it is different in Google Maps: Maps will give you -33.866745,151.195733 so you have to change the order before entering it into the emulator!
However, manually typing into telnet isn’t too convenient either, so I’ve written a simple python script that does it for me. It will keep setting the coordinates every second, emulating the real GPS hardware, which would do the same.
Feel free to modify to suit your needs:
import sys import telnetlib import time HOST = "localhost" tn = telnetlib.Telnet(HOST,5554) print "Setting location, press CTRL+C to stop" while True: tn.write("geo fix 151.195733 -33.866745\n") # GOOG HQ SYD time.sleep(1) tn.close()