Skip to content

Commit 8354940

Browse files
committed
Improve handling of Scan permissions
Previously they could be rejected with an empty grant results array, which crashed here. With this, that should be considered as a clean cancellation instead.
1 parent 444397a commit 8354940

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

app/src/main/java/tech/httptoolkit/android/ScanActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ScanActivity : AppCompatActivity(), ZXingScannerView.ResultHandler {
5757
grantResults: IntArray
5858
) {
5959
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
60-
if (grantResults[0] == PERMISSION_GRANTED) {
60+
if (grantResults.isNotEmpty() && grantResults[0] == PERMISSION_GRANTED) {
6161
Log.i(TAG, "Camera permissions granted")
6262
} else {
6363
Log.i(TAG, "Camera permissions rejected")

0 commit comments

Comments
 (0)