From cb11486f66884fe91ed6c98567a06fff69d0eb66 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Wed, 16 Oct 2013 11:44:21 -0700 Subject: [PATCH] Backporting CB-4521 --- framework/src/org/apache/cordova/GeoBroker.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/framework/src/org/apache/cordova/GeoBroker.java b/framework/src/org/apache/cordova/GeoBroker.java index 4a07b738..ca86a313 100644 --- a/framework/src/org/apache/cordova/GeoBroker.java +++ b/framework/src/org/apache/cordova/GeoBroker.java @@ -55,14 +55,18 @@ public class GeoBroker extends CordovaPlugin { * @return True if the action was valid, or false if not. */ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if (this.locationManager == null) { - this.locationManager = (LocationManager) this.cordova.getActivity().getSystemService(Context.LOCATION_SERVICE); - this.networkListener = new NetworkListener(this.locationManager, this); - this.gpsListener = new GPSListener(this.locationManager, this); + if (locationManager == null) { + locationManager = (LocationManager) this.cordova.getActivity().getSystemService(Context.LOCATION_SERVICE); } if ( locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER ) || locationManager.isProviderEnabled( LocationManager.NETWORK_PROVIDER )) { + if (networkListener == null) { + networkListener = new NetworkListener(locationManager, this); + } + if (gpsListener == null) { + gpsListener = new GPSListener(locationManager, this); + } if (action.equals("getLocation")) { boolean enableHighAccuracy = args.getBoolean(0);