Skip to content

Commit

Permalink
Merge pull request #18 from ingvardm/feature/export-areProvidersAvail…
Browse files Browse the repository at this point in the history
…able

Feature/export areProvidersAvailable
  • Loading branch information
MustansirZia authored Feb 10, 2018
2 parents f571135 + 8a219b1 commit f5b56da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
*/
Expand Down
2 changes: 2 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Dumb = {
setLocationInterval: noIOS,
setFastestLocationInterval: noIOS,
setSmallestDisplacement: noIOS,
areProvidersAvailable: noIOS,
};

const Location = Platform.OS === 'ios' ? Dumb : {
Expand All @@ -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,
Expand Down

0 comments on commit f5b56da

Please sign in to comment.