Skip to content

Commit

Permalink
Fix crash when apps goes background, and ask for location enabling wh…
Browse files Browse the repository at this point in the history
…en come back in foreground
  • Loading branch information
Richou committed Jul 13, 2018
1 parent a3a4a5c commit 5b75d3d
Show file tree
Hide file tree
Showing 3 changed files with 2,783 additions and 1,652 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,20 @@ public void onResult(@NonNull LocationSettingsResult locationSettingsResult) {
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
if (promise != null) promise.resolve("already-enabled");
this.promise = null;
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
try {
status.startResolutionForResult(getCurrentActivity(), REQUEST_CHECK_SETTINGS);
} catch (IntentSender.SendIntentException exception) {
Log.e(TAG, "Failed to show dialog", exception);
if (promise != null) promise.reject(ERR_FAILED_OPEN_DIALOG_CODE, new RNAndroidLocationEnablerException("Failed to show dialog", exception));
this.promise = null;
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
if (promise != null) promise.reject(ERR_SETTINGS_CHANGE_UNAVAILABLE_CODE, new RNAndroidLocationEnablerException("Settings change unavailable"));
this.promise = null;
break;
}
}
Expand All @@ -129,6 +132,7 @@ public void onActivityResult(Activity activity, int requestCode, int resultCode,
} else {
promise.reject(ERR_USER_DENIED_CODE, new RNAndroidLocationEnablerException("denied"));
}
this.promise = null;
}
}

Expand Down
Loading

0 comments on commit 5b75d3d

Please sign in to comment.