1. simulator simulating Gps
When simulating Gps in a simulator, you must first Open the DDMS view. In eclipse, choose Windows> Open Perspective> Others> DDMS.
In the DDMS view, open the Emulator Control tab, select the Manual sub-tab in the Location Controls group, enter the value in the longitude and latitude, and click Send to simulate a single Gps Positioning coordinate.
2. Use a real machine (android phone) to test Gps
When you use a real machine to test Gps, You need to test it in an outdoor, empty place, where the Gps signal is slightly stronger. It is best to take the mobile phone to the outside and run a circle to obtain the location data. Otherwise, the returned Location is NULL.
3. Code Implementation
AndroidManifest. xml
<Uses-permission android: name = "android. permission. ACCESS_FINE_LOCATION"/>
// Obtain LocationManagerLocationManager locationManager = (LocationManager) getSystemService (Context. LOCATION_SERVICE); // obtain the GPS PROVIDERLocationProvider locationPrivider = locationManager. getProvider (LocationManager. GPS_PROVIDER); // obtain LocationLocation location = locationManager. getLastKnownLocation (LocationManager. GPS_RPOVIDER );