Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected Boolean locationUpdates(Boolean needed) {
- if (needed) {
- locationManager = (LocationManager) CaptureRouteActivity.this.getSystemService(Context.LOCATION_SERVICE);
- networkListener = new LocationListener() {
- public void onLocationChanged(Location location) {
- makeUseOfNetwork(location);
- }
- public void onStatusChanged(String provider, int status, Bundle extras) {
- }
- public void onProviderEnabled(String provider) {
- }
- public void onProviderDisabled(String provider) {
- }
- };
- gpsListener = new LocationListener() {
- public void onLocationChanged(Location location) {
- makeUseOfGPS(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, 000, 0, networkListener);
- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 000, 0, gpsListener);
- locationManager=null;
- /*
- * The two integers in this request are the time (ms) and distance
- * (m) intervals of notifications respectively.
- */
- return true;
- }
- if (!needed) {
- locationManager = (LocationManager) CaptureRouteActivity.this.getSystemService(Context.LOCATION_SERVICE);
- networkListener = new LocationListener() {
- public void onLocationChanged(Location location) {
- makeUseOfNetwork(location);
- }
- public void onStatusChanged(String provider, int status, Bundle extras) {
- }
- public void onProviderEnabled(String provider) {
- }
- public void onProviderDisabled(String provider) {
- }
- };
- gpsListener = new LocationListener() {
- public void onLocationChanged(Location location) {
- makeUseOfGPS(location);
- }
- public void onStatusChanged(String provider, int status, Bundle extras) {
- }
- public void onProviderEnabled(String provider) {
- }
- public void onProviderDisabled(String provider) {
- }
- };
- // Kill location Listeners
- locationManager.removeUpdates(networkListener);
- locationManager.removeUpdates(gpsListener);
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement