Simulating GPS Position
On an emulator there is no GPS, but you can simulate positioning at specific GPS coordinates by one of the following two procedures.
To set a test position in the phone emulator: Press Home on the emulator, open the apps menu, choose Maps, click the Menu button, and then click the My Location item (looks like a target). Now go to Eclipse and select the DDMS perspective at the top right. On the left panel of the resulting screen scroll down to Location Controls, select the Manual tab, and enter the desired longitude and latitude in degrees (note that longitude is first). Then click Send. The phone emulator should now show these coordinates as its location. Click on the Java perspective at the top right of Eclipse to return to the editor.
A test position can also be set using the telnet console for the phone. To telnet to the console of the emulator using port 5554 (port displayed on emulator screen) issue from a shell window
telnet localhost 5554
Then available commands can be obtained with "telnet help". To set GPS coordinates, after a telnet to the port issue
geo fix <longitude-degrees> <latitude-degrees> <altitude-meters>
NOTE THE ORDER: longitude, then latitude, and it is in degrees. This is different from the order (latitude then longitude) and units (microdegrees) that are standard in the API. Specifying the altitude is optional.
| When I first began investigating Android location services I sent a virtual device to the coordinates of Knoxville, Tennessee, where I live, and found that the map display turned solid white, whether satellite 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 that to send the virtual device to a set of coordinates the latitude and longitude order had to be reversed from that for the API. If you switch latitude and longitude for Knoxville, it places you in the middle of Antarctica! |