Android Question Duplicate USES-PERMISSION

Semen Matusovskiy

Well-Known Member
Licensed User
Hi, guys --

This topic already discussed two years ago - https://www.b4x.com/android/forum/t...roid-permission-write_external_storage.72435/

All is clear, except how to struggle with troubles. Is any solution now ?

In my case I set <uses-permission android:name="android.permission.CAMERA" android:maxSdkVersion="22"/> in manifest editor.
B4A adds automatically <uses-permission android:name="android.permission.CAMERA"/> (because I use Camera library, if user doesn't want to use Camera application).

Like result - my declaration is ignored and under SDK23+ intent requires run-time permission, which is not really needed.
 

Semen Matusovskiy

Well-Known Member
Licensed User
The history is following. At first, I wrote own activity , which makes a photo. Enough simple code, not a lot of possibilities. Then some users wanted the same possibilities as in Camera application. I added intent and offer choice between two variants. If user selected Camera application, how to explain to him, why my program wants camera permissions ? Any ideas ?
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
That's why "Privacy Policies" exist, but even though, you will have users complaining and giving you 1 star ratings because your app requires such and such permission, my advise to you, when the app is installed, display an explanation of why some permissions are needed, also, make that clear on you Google Play page.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Thanks, Erel. Nice feature and fixes WRITE_EXTERNAL_STORAGE with maxSdkVersion=18.

But for Camera I can't find solution, which allows to offer both variants (my activity and intent) and do not ask run-time permission for intent.
If to specify CAMERA with maxSdkVersion="22", it's not possible to use my activity under SDK23+ (runtimepermission.CheckAndRequest doesn't work)
If to specify CAMERA without maxSdkVersion="22", it's necessary to ask permission for intent.
I am afraid, I need to use NJDude advice.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Please, take your own sample https://www.b4x.com/android/forum/threads/intent-based-camera.69215/
Add: 1) reference to Camera library ; 2) Dim c As Camera in Sub Globals and run under Android 6+
You will receive
B4X:
(SecurityException) java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.android.camera2/com.android.camera.CaptureActivity clip={text/uri-list U:content://b4a.example3.provider/name/tempimage.jpg} (has extras) } from ProcessRecord{9c2344a 6612:b4a.example3/u0a82} (pid=6612, uid=10082) with revoked permission android.permission.CAMERA

If to ask run-time permission for Camera everything works.
 
Upvote 0
Top