Skip to content

Commit

Permalink
Use context for location provider if activity is not available
Browse files Browse the repository at this point in the history
The current activity may be null when the location provider is created.
Use the React application context in that case.
  • Loading branch information
tkuenzle committed May 27, 2019
1 parent 163ea51 commit b895c4d
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ public class RNPlayServicesLocationProvider implements RNLocationProvider {

public RNPlayServicesLocationProvider(Activity activity, ReactApplicationContext context) {
this.context = context;
locationProvider = LocationServices.getFusedLocationProviderClient(activity);
locationSettingsClient = LocationServices.getSettingsClient(activity);
if (activity != null) {
locationProvider = LocationServices.getFusedLocationProviderClient(activity);
locationSettingsClient = LocationServices.getSettingsClient(activity);
} else {
locationProvider = LocationServices.getFusedLocationProviderClient(context);
locationSettingsClient = LocationServices.getSettingsClient(context);
}
}

// Public interface
Expand Down

0 comments on commit b895c4d

Please sign in to comment.