GitHub user shawnlinboy opened a pull request:
https://github.com/apache/incubator-weex/pull/1221
[android] modify playground app camera runtime permission request behavior
For `ActivityCompat.shouldShowRequestPermissionRationale()`, it means your
app should display a dialog or something else to explain why you are going to
request this permission, and **try again to request the permission**, see
https://developer.android.com/training/permissions/requesting and
https://github.com/googlesamples/android-RuntimePermissionsBasic/blob/master/Application/src/main/java/com/example/android/basicpermissions/MainActivity.java#L124
For the original code, if the permission was **NOT** granted, the
`ContextCompat.checkSelfPermission(mWXSDKInstance.getContext(),
Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED` will always
returns `true` and
`ActivityCompat.shouldShowRequestPermissionRationale((Activity)
mWXSDKInstance.getContext(), Manifest.permission.CAMERA)` did the same thing,
which means If a user tap `æ«æäºç»´ç `, the `Weex playground need the
camera permission to scan QR code` toast will always show up without prompting
a permission request dialog, users have to navigate to system app management
and grant permission manually. If one user was not familiar with this
mechanism,the Playground app will always be not able to scan code.
This patch fix can show a dialog to tell user that `Weex playground need
the camera permission to scan QR code` **and then request this code
immediately**, it will make the a system permission dialog alert and the user
can now grant permission directly.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/shawnlinboy/incubator-weex
android-bugfix-add_camera_scan_permission_check
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-weex/pull/1221.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1221
----
commit f3a2bd46ac746faa76016ef2cd8f1704e16441d6
Author: Shen Lin <shhenlin@...>
Date: 2018-05-29T11:22:35Z
[android] modify playground app camera runtime permission request behavior
----
---