Android Development – Setting your location using latitude, longitude in the emulator

This is a quick post since it took me a little while to figure this one out. If you are using location services in your application and testing them on the emulator, you might be wondering how to set your location. In fact the iPhone doesn’t provide for this and defaults you to Cupertino (Apple’s HQ) which can be annoying.

But Google have thought a bit more about it. All you need to know is the port your emulator is running on (it’ll be in the title bar of the emulator), typically 5554.

Fire up a terminal and away you go, let’s say you want to set it around London, UK. That is roughly 52,0 in lat long so connect to the port through Telnet and enter:

telnet localhost 5554
geo fix 52 0 0

The final 0 is optional and sets your altitude. Easy, and now in your application your callback method onLocationChanged should be called.

Leave a Reply

Your email address will not be published. Required fields are marked *