Android Question [Solved] No more request to enable camera access after changing android:targetSdkVersion in manifest from 22 to 30

sdesan

Member
Licensed User
Longtime User
Hi everyone,
after simple changing android:targetSdkVersion in manifest from 22 to 30 i don't have more request to enable camera access so i need to enable manually access to camera in appa setting.

this is my manifest

B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
AddManifestText(<uses-feature android:name="android.hardware.telephony" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />)
AddPermission("android.permission.INTERNET")
AddPermission("android.permission.CAMERA")
AddPermission("android.hardware.camera")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

I'm using B4A Ver. 11.80 (64 bit)

Libraries used:
Core
OkHttpUtils2
QRCodeReaderView
XUI

Thank you in advance
 

DonManfred

Expert
Licensed User
Longtime User
You are not using Runtimepermission and even not requesting for the permission?
Why?

MANDATORY READ and understand

You are also not adding the right Permission in the manifest.


B4X:
 ' Required to be able to access the camera device.
AddPermission(android.permission.RECORD_AUDIO)  ' Allows an application to record audio.

try remove these 3 or at least camera
B4X:
AddManifestText(<uses-feature android:name="android.hardware.telephony" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />)



Start with this Example:

If you are using B4XPages then use this Example

Does it work?
 
Last edited:
Upvote 0

sdesan

Member
Licensed User
Longtime User
Thank you for the answer
I changed manifest with no success

B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.CAMERA)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

i've also removed " from AddPermission lines

In your

' Required to be able to access the camera device.
AddPermission(android.permission.RECORD_AUDIO) ' Allows an application to record audio.
Probably you did not report some words, but also with those permissions ther is not camera rights request
-> AddPermission(android.permission.CAMERA) ' Required to be able to access the camera device. <-
AddPermission(android.permission.CAPTURE_AUDIO_OUTPUT) ' Allows an application to capture audio output.

My manifest is based on QRCodeReaderView and if in manifest i write <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="22"/> during first app start i have camera permission request
 
Upvote 0

sdesan

Member
Licensed User
Longtime User
Maybe I missed a few pieces or I didn't explain myself. I need to read qr code.

For doing what i need, i use the 'a SEVEN YEARS old Library' that works perfectly but if if in manifest i write <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="30"/> the first time i use app there is not request of camera permission. If i change 30 in 22 i receive camera permission resquest.

All clear?

CameraEX example works but is not a qrreader, is a simple camera picture maker.

Thanks for your support anyway
 
Upvote 0

sdesan

Member
Licensed User
Longtime User
Hi Hamied,
thanks for the answer.

I want everytime camera permission request to end app users, but when i targeting 30 sdk (also 23,24,25 ecc.) this does not happen.

And unfortunately I don't understand Don Manfred solution, sorry
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
Now the example used in the QRCodeReaderView library will not work if you targeting recent android sdk.
Download that example and change the following:
1- Check the library Runtimepermission in library tab
2- change the code of b1_Click event to:
B4X:
Sub b1_Click
   
    Dim rp As RuntimePermissions
    rp.CheckAndRequest(rp.PERMISSION_CAMERA)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then

        qrcrv.Visible = True
        DoEvents
        qrcrv.startScan

    End If
   
End Sub
Then the example will work, so reflect the changes in your app.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…