too long time to obtain user location?
I'm beginner in android development . The problem is the code take several minutes to obtain user location so how i can fix this proble开发者_如何转开发m? please help me
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
Toast.makeText(getBaseContext(),
"Location changed : Lat: " + location.getLatitude() +
" Lng: " + location .getLongitude(),
Toast.LENGTH_SHORT).show();
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
lm.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
0,
0,
locationListener);
GPS is always slow to start and doesn't work inside. You might want to read this:
I'm a big fan of location-based apps, but not their seemingly-inevitable startup latency.
Whether it's finding a place to eat or searching for the nearest Boris Bike, I find the delay while waiting for the GPS to get a fix, and then for the results list to populate, to be interminable. Once I’m in a venue and ready to get some tips, check-in, or review the food, I’m frequently thwarted by a lack of data connection.
精彩评论