There are books online, in the code Google official api documentation are still unable to obtain
try
LocationManager locManager = (LocationManager) getSystemService (Context.LocationService);
Criteria criteria = new Criteria ();
criteria.setAccuracy (Criteria.ACCURACY_FINE);
criteria.setPowerRequirement (Criteria.POWER_LOW);
criteria.setAltitudeRequired (false);
criteria.setBearingRequired (false);
criteria.setCostAllowed (false) ;/ / do not need to spend money
String provider = locManager.getBestProvider (criteria, true) ;/ / addGpsStatusListener (listener);
Location location = locManager.getLastKnownLocation (provider);
locManager.requestLocationUpdates (LocationManager.GPS_PROVIDER, 1000, 10, listener);
This method can not get to the back of the locManager.requestLocationUpdates (LocationManager.GPS_PROVIDER, 1000, 10, listener); This request updates, simply do not call the listener inside the code
LocationManager locationManager = (LocationManager) this.getSystemService (Context.LOCATION_SERVICE);
/ / Define a listener that responds to locationupdates
LocationProvider provider = locationManager.getProvider (LocationManager.NETWORK_PROVIDER);
LocationListener locationListener = new LocationListener () {public void onLocationChanged (Location location) {/ / Called when a new location is found by the network
makeUseOfNewLocation (location);} public void onStatusChanged (String provider, int status, Bundle extras) {} public void onProviderEnabled (String provider) {} public void onProviderDisabled (String provider) {}};
/ / Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates (LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
Google would not be able to get to this, not the past strange thing is I can get 1.6 phone location, but have access to less than 2.1!
Help ah, help ah
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
2.2 I can interview on ah. You can go online and try a GPS program look okay, such as using GOOGLE position with GPS positioning.
Reply:
I think it is not about the location to the phone first with the application for the job, ah, because I get this phone used to apply some geographic location.
Reply:
Location location = locManager.getLastKnownLocation (provider) ;/ / get the last known coordinates
locManager.requestLocationUpdates (LocationManager.GPS_PROVIDER, 1000, 10, listener) ;/ / move more than 10 meters and the interval is greater than one second, will send a message, the speed of 5 meters per second, 10 m 2 seconds once per> 1 seconds,
So, if your phone has never been used on the GPS fixed position, which is no lastknown
Then you do not move, so nothing happens
Reply:
Thank you know the
Reply:

Reply:
Positive Solutions
Reply:
But I also tested one, whether it is changed (1000,0) or (1000,1) will not work, he did not even call the listener inside the method, continue to solve!
Reply:
Xml file is not located inside the authority did not join ah?
Reply:
1, to ensure your GPS open;
2, to ensure the appropriate permissions you have configured in XML;
3, do not play in the room, because the room is generally no GPS signal;
Reply:
That is the general three. . Good
Reply:
Seems not how the outdoor gps signal
Reply:
Permissions certainly add up, or will be error, usually playing in the room, that room to get you through the base station
Reply:
The service is licensed android cover it up ... or Province
Reply:
If android service flooded, and why other status applications can use?
Reply:
And you encounter the same problem, Baidu map can locate, I can not write their own positioning, seemingly put google maps also have problems.
No comments:
Post a Comment