Previous  | Next  | Home

Simulating GPS Position


 

It is best to develop apps using location services and GPS positioning on actual devices with GPS hardware. However, although an emulator has no GPS, you can simulate positioning at specific GPS coordinates in a pinch for an AVD running your location-enabled app. See the discussion in Providing Mock Location Data, where methods to systematically test location services for devices without physically going to those locations are discussed.


One method for inserting mock position data is really oldschool: you can telnet to the emulator (yes telnet!) and give it mock latitude and longitude position data. When I first began investigating Android location services (before I even had an Android device), I used the telnet interface to send a virtual device running a mapping app that I was developing to the coordinates of Knoxville, Tennessee, where I live, and found that the map display turned solid white, whether satellite view or map view was toggled.

It took me a few minutes to realize that there was nothing wrong at all with my program. I had not noticed in the documentation that to send the virtual device to a set of coordinates using the telnet interface the latitude and longitude order had to be reversed from that normally assumed for methods in the Android API. If you switch latitude and longitude for Knoxville, it places you in the middle of Antarctica!

Last modified: June 10, 2016


Previous  | Next  | Home