summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Naganov <mnaganov@google.com>2016-02-19 11:20:31 -0800
committerMikhail Naganov <mnaganov@google.com>2016-02-19 11:20:31 -0800
commit9267faa62a0fa5196298296eb48bd14f3ee512f9 (patch)
tree741bf72892b7c82982665c50fb2017ae0371be94
parent8be22673ce07696672ad3980adaaedf80caa9d7f (diff)
downloadHTMLViewer-9267faa62a0fa5196298296eb48bd14f3ee512f9.tar.gz
Fix crash in onRequestPermissionsResult due to empty grantResults
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
-rw-r--r--src/com/android/htmlviewer/HTMLViewerActivity.java3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/com/android/htmlviewer/HTMLViewerActivity.java b/src/com/android/htmlviewer/HTMLViewerActivity.java
index aca339f..20f2edc 100644
--- a/src/com/android/htmlviewer/HTMLViewerActivity.java
+++ b/src/com/android/htmlviewer/HTMLViewerActivity.java
@@ -108,9 +108,8 @@ public class HTMLViewerActivity extends Activity {
// 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 {