If you are using monkeyrunner, you can use this function:
def telnet(host, port): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(2) # connect to remote host try : s.connect((host, port)) except : print 'Unable to connect' sys.exit() print 'Connected to remote host' return s def geo_fix(port, lat, lng): print "setting gps to " + str(lat) + "," + str(lng) socket = telnet("localhost", port) socket.send("geo fix " + str(lng) + " " + str(lat) + "\n") socket.send("exit\n") socket.close() geo_fix(5554, 32.0878802, 34.797246)
I could not find a way to get the emulator port from MonkeyDevice, so I manually pass the port, but it would be better if we could understand this from the device object
source share