Hi guys,
I'm facing a weird problem while trying to understand Android's Runtimepermission.
I've followed the Erel's tutorial here:
https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/
It seems that does not matter what is the setting give to a resource (the Camera in this case), the CheckAndRequest methods always return TRUE!
I've done this snippet of code:
I'm testing it on a real device with Android 6.
In the APP security menu, if I set ASK FOR ACCESS to the Camera, then as soon I get to the CheckAndRequest I see a popup dialog from the OS, asking me what to do.
Then, any button I press (DISALLOW or GRANT) the return from CheckAndRequest is always true.
If I choose, from the above dialog the option DISALLOW, then the next time I try to run it, the dialog for the choice is not even shown, and the application hangs/close.
This is my manifest file:
Anybody knows why this happen?
I'm using B4A 8.0, Real Device Android 6. Attached is also a screenshot from the SDK manager, if this make a difference.
Thank you.
I'm facing a weird problem while trying to understand Android's Runtimepermission.
I've followed the Erel's tutorial here:
https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/
It seems that does not matter what is the setting give to a resource (the Camera in this case), the CheckAndRequest methods always return TRUE!
I've done this snippet of code:
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private rp As RuntimePermissions
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("company_layout")
rp.CheckAndRequest(rp.PERMISSION_CAMERA)
wait for Activity_PermissionResult (permission As String, Result As Boolean)
If Result = True Then
Log("Camera is permitted")
Else
Log("No Camera Permission")
End If
End Sub
I'm testing it on a real device with Android 6.
In the APP security menu, if I set ASK FOR ACCESS to the Camera, then as soon I get to the CheckAndRequest I see a popup dialog from the OS, asking me what to do.
Then, any button I press (DISALLOW or GRANT) the return from CheckAndRequest is always true.
If I choose, from the above dialog the option DISALLOW, then the next time I try to run it, the dialog for the choice is not even shown, and the application hangs/close.
This is my manifest file:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<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="true" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.flash" android:required="false" />)
AddManifestText(<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />)
'AddPermission("android.permission.ACCESS_COARSE_LOCATION")
AddPermission("android.permission.INTERNET")
AddPermission("android.permission.ACCESS_FINE_LOCATION")
AddPermission("android.permission.WAKE_LOCK")
AddPermission("android.permission.DEVICE_POWER")
'AddPermission("android.permission.ACCESS_COARSE_UPDATES")
AddPermission("android.permission.READ_PHONE_STATE")
AddPermission("android.permission.VIBRATE")
AddPermission("android.permission.CAMERA")
AddPermission("android.permission.FLASHLIGHT")
AddPermission("android.hardware.camera")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetActivityAttribute(client_activity, android:windowSoftInputMode, adjustResize|stateHidden)
'End of default text.
'********* TabStrip ***********************
CreateResource(drawable, background_tab.xml,
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_shortAnimTime">
<item android:state_pressed="true" android:drawable="@color/background_tab_pressed" />
<item android:state_focused="true" android:drawable="@color/background_tab_pressed"/>
<item android:drawable="@android:color/transparent"/>
</selector>)
CreateResource(values, colors.xml,
<resources>
<color name="background_tab_pressed">#6633B5E5</color>
</resources>)
'******************************************
SetActivityAttribute(dati_activity, android:windowSoftInputMode, adjustResize|stateHidden)
Anybody knows why this happen?
I'm using B4A 8.0, Real Device Android 6. Attached is also a screenshot from the SDK manager, if this make a difference.
Thank you.
Attachments
Last edited: