I have this code for asking runtime permission and it works fine on most of devices.
On a Huawey tablet (Android 9) it works fine in debug and release, but when the app is downloaded from PlayStore the permission request is not executed. In fact, if I go in setting-app-my app-permission I see that all the permissions are unflagged (of course the app then crash).
On other devices like my Samsung (same Android 9) the permission request is always executed, also when the app is downloaded from PlayStore.
Any Idea ?
These the relevant code in the manifest
On a Huawey tablet (Android 9) it works fine in debug and release, but when the app is downloaded from PlayStore the permission request is not executed. In fact, if I go in setting-app-my app-permission I see that all the permissions are unflagged (of course the app then crash).
On other devices like my Samsung (same Android 9) the permission request is always executed, also when the app is downloaded from PlayStore.
Any Idea ?
B4X:
Sub Activity_Create(FirstTime As Boolean)
If Starter.PermissionOk=False Then
wait for (CheckPermission1) complete (result As Boolean)
If result=False Then
Activity.Finish
Return
End If
wait for (CheckPermission2) complete (result As Boolean)
If result=False Then
Activity.Finish
Return
End If
wait for (CheckPermission3) complete (result As Boolean)
If result=False Then
Activity.Finish
Return
End If
wait for (CheckPermission4) complete (result As Boolean)
If result=False Then
Activity.Finish
Return
End If
End If
Log("All permission ok")
File.WriteString(Starter.AppPath,"PermOk","")
Starter.PermissionOk=True
End Sub
Sub CheckPermission1 As ResumableSub
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
wait for Activity_PermissionResult(Permission As String, Result As Boolean)
Return Result
End Sub
Sub CheckPermission2 As ResumableSub
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
wait for Activity_PermissionResult(Permission As String, Result As Boolean)
Return Result
End Sub
Sub CheckPermission3 As ResumableSub
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_COARSE_LOCATION)
wait for Activity_PermissionResult(Permission As String, Result As Boolean)
Return Result
End Sub
Sub CheckPermission4 As ResumableSub
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_PHONE_STATE)
wait for Activity_PermissionResult(Permission As String, Result As Boolean)
Return Result
End Sub
These the relevant code in the manifest
B4X:
......
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
AddApplicationText(
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaS.......................hJmc"/>
)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
AddPermission(android.permission.READ_PHONE_STATE)
AddPermission(android.permission.PERMISSION_ACCESS_FINE_LOCATION)
AddApplicationText(
<provider
android:name="android.support.v4.content.FileProvider"
......