Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Fix crash in onRequestPermissionsResult due to empty grantResults
Browse files Browse the repository at this point in the history
In the case when the permission request dialog is displayed and the
device is changing orientation, the callback will be called with empty
grantResults array. The code needs to take this case into account.

Bug: 27237709
Change-Id: I450d365fcdfa308a69265d75391661fa64028734
  • Loading branch information
Mikhail Naganov committed Feb 19, 2016
1 parent 8be2267 commit 9267faa
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/com/android/htmlviewer/HTMLViewerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ public void onRequestPermissionsResult(int requestCode,
// We only ever request 1 permission, so these arguments should always have the same form.
assert permissions.length == 1;
assert Manifest.permission.READ_EXTERNAL_STORAGE.equals(permissions[0]);
assert grantResults.length == 1;

if (PackageManager.PERMISSION_GRANTED == grantResults[0]) {
if (grantResults.length == 1 && PackageManager.PERMISSION_GRANTED == grantResults[0]) {
// Try again now that we have the permission.
loadUrl();
} else {
Expand Down

0 comments on commit 9267faa

Please sign in to comment.