I have a ListView that is bound to a data adapter that displays distances of fixed landmarks after I create and load my location object with the device's geoloc (lat/long). The problem is, on average, the code below takes 3-7 seconds to load, the longer process is the call "requestLocationUpdates()" which sometimes can take minutes to load if there is no NETWORK_SERVICE and the GPS_SERVICE becomes the primary, making my Activity ListView blank
Is the OnCreate() Activity method the best place for requestLocationUpdates() to be called?
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); locationListener = new GeoLocationListener();
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(false);
criteria.setSpeedRequired(false);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String provider = locationManager.getBestProvider(criteria, true);
locationManager.requestLocationUpdates(provider,
0, //300000, // TODO: Default to Check Every 5 Minutes OR
0, //500, // TODO: Default to Check if device moves more than 500 meters
locationListener);