diff --git a/android/src/main/java/com/mustansirzia/fused/FusedLocationModule.java b/android/src/main/java/com/mustansirzia/fused/FusedLocationModule.java index 35b4dc3..6b2232a 100644 --- a/android/src/main/java/com/mustansirzia/fused/FusedLocationModule.java +++ b/android/src/main/java/com/mustansirzia/fused/FusedLocationModule.java @@ -180,6 +180,18 @@ public void stopLocationUpdates() { } } + @ReactMethod + public boolean areProvidersAvailable() { + LocationManager lm = (LocationManager)getReactApplicationContext().getSystemService(Context.LOCATION_SERVICE); + boolean gps_enabled = false; + try { + gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER) || lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + } catch(Exception ex) { + Log.e(TAG, ex.toString()); + } + return gps_enabled; + } + // ~ https://stackoverflow.com/questions/ // 22493465/check-if-correct-google-play-service-available-unfortunately-application-has-s private boolean checkForPlayServices() { @@ -225,17 +237,6 @@ private LocationRequest buildLR() { return request; } - private boolean areProvidersAvailable() { - LocationManager lm = (LocationManager)getReactApplicationContext().getSystemService(Context.LOCATION_SERVICE); - boolean gps_enabled = false; - try { - gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER) || lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER); - } catch(Exception ex) { - Log.e(TAG, ex.toString()); - } - return gps_enabled; - } - /* * Internal function for communicating with JS */ diff --git a/main.js b/main.js index 2e26ce0..600378f 100644 --- a/main.js +++ b/main.js @@ -19,6 +19,7 @@ const Dumb = { setLocationInterval: noIOS, setFastestLocationInterval: noIOS, setSmallestDisplacement: noIOS, + areProvidersAvailable: noIOS, }; const Location = Platform.OS === 'ios' ? Dumb : { @@ -41,6 +42,7 @@ const Location = Platform.OS === 'ios' ? Dumb : { setLocationInterval: FusedLocation.setLocationInterval, setFastestLocationInterval: FusedLocation.setFastestLocationInterval, setSmallestDisplacement: FusedLocation.setSmallestDisplacement, + areProvidersAvailable: FusedLocation.areProvidersAvailable, Constants: { HIGH_ACCURACY: 0, BALANCED: 1,