When obtaining GPS information on the simulator, use location loc = locationmanager. getlastknownlocation ("GPS"); To obtain location information, but LOC is usually null in debugging, because you need to manually add GPS information to the simulator first, there are two ways to manually add
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 ).
Android Console: Type 'help' for a list of commands
OK.
(2) Use the GEO command to simulate GPS signal sending:
GEO fix Longitude Latitude,
For example, GEO fix 116.37 39.95
(3) a gps mark is added to the status bar of the simulator ~ Use location loc = locationmanager. getlastknownlocation ("GPS") to obtain the coordinates ~~