Backporting CB-4521

This commit is contained in:
Joe Bowser 2013-10-16 11:44:21 -07:00
parent 0e9b446a81
commit cb11486f66

View File

@ -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);