When I use Baidu map to display my bus routes, I need to use GPS longitude and latitude. However, we all know that when obtaining GPS information on the simulator, I use location loc = locationmanager. getlastknownlocation ("GPS"); To obtain location information, but LOC is usually null during debugging. The reason is that the simulator cannot directly obtain the longitude and latitude. We can manually set it on the simulator, provided that your simulator must be in the starting status.
You can manually add GPS information to the simulator in either of the following ways:
1. In eclipse, manually set the longitude and latitude under windows --> open perspective --> ddms --> emulator control --> manual, and press the send button.
2. manually add information under cmd.
(1) first open the simulator, run cmd, and enter Telnet localhost 5554 (Note: 5554 is the port of the simulator on the local machine. It may be different. The specific port number, in the upper-left corner of the simulator), the android Console: Type 'help' for a list of commandsok is displayed.If you are a friend of win7, the console may prompt that telnet is invalid or something, because telnet is not displayed by default in win7 and needs to be opened manually. Specifically: [1] control panel --> program --> enable or disable the WINDOWS function, and then select the telnet server and Telnet client. [2] Then manually start Telnet in management tools> services
(2) Use the GEO command to simulate GPS signal sending:
GEO fix Longitude Latitude
(3) a gps icon is added to the status bar of the simulator, and the icon of a small radar appears. Then, use location loc = locationmanager. getlastknownlocation ("GPS"); then you can get the coordinates.