Hello,
I am referring to this post : https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/
As I understand it, CheckAndRequest would open the dialog we see when an app needs some dangerous permissions (listed). But some dangerous permissions don't open the confirmation dialog.
Manifest (I tried to declare and not declare - code below)
Paths
Code (project attached)
Permissions detected by B4A
Project attached if you would like to try
I am referring to this post : https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/
As I understand it, CheckAndRequest would open the dialog we see when an app needs some dangerous permissions (listed). But some dangerous permissions don't open the confirmation dialog.
Manifest (I tried to declare and not declare - code below)
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
AddPermission("android.PERMISSION_RECORD_AUDIO")
Paths
Code (project attached)
B4X:
#Region Project Attributes
#ApplicationLabel: CheckPermissions
#VersionCode: 1
#VersionName: 1
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private RP As RuntimePermissions
Private AR As AudioRecordApp 'for testing only (Thought we needed something to force the permission)...
Dim PS As PhoneSensors
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
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("Layout1")
If FirstTime Then
AR.Initialize("AR")
PS.Initialize(21) 'TYPE_HEART_RATE
End If
CheckPermissions
End Sub
Sub Activity_Resume
PS.StartListening("PS")
PS.StopListening
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub CheckPermissions
RP.CheckAndRequest(RP.PERMISSION_RECORD_AUDIO)
End Sub
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
Log($"Permission: ${Permission}
Result: ${Result}"$)
Select Permission
Case RP.PERMISSION_RECORD_AUDIO
CheckCheck(RP.PERMISSION_ACCESS_FINE_LOCATION)
Case RP.PERMISSION_ACCESS_FINE_LOCATION
CheckCheck(RP.PERMISSION_BODY_SENSORS)
Case RP.PERMISSION_BODY_SENSORS
CheckCheck(RP.PERMISSION_WRITE_EXTERNAL_STORAGE) 'this one works
End Select
End Sub
Sub CheckCheck(What As String)
RP.CheckAndRequest(What)
End Sub
Permissions detected by B4A
Project attached if you would like to try