Android Question App Abort Execution Library RuntimePermissions

ovasquez

Member
Licensed User
Longtime User
Good Nigth

I have the following problem (B4A 8.30):

My application aborts the execution when executing these statements in Release mode

If rp.Check (rp.PERMISSION_WRITE_EXTERNAL_STORAGE) = False Then
rp.CheckAndRequest (rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
End If
If rp.Check (rp.PERMISSION_READ_PHONE_STATE) Then
rp.CheckAndRequest (rp.PERMISSION_READ_PHONE_STATE)
End If

manifiest.
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)


In debug mode it works normally

Thanks for your Help.

Excuse mi english
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Good Nigth

I have the following problem (B4A 8.30):

My application aborts the execution when executing these statements in Release mode

If rp.Check (rp.PERMISSION_WRITE_EXTERNAL_STORAGE) = False Then
rp.CheckAndRequest (rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
End If
If rp.Check (rp.PERMISSION_READ_PHONE_STATE) Then
rp.CheckAndRequest (rp.PERMISSION_READ_PHONE_STATE)
End If

manifiest.
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)


In debug mode it works normally

Thanks for your Help.

Excuse mi english

Is there any error in the logs when it crashes (also check unfiltered logs)?

You might want to review the runtime permissions tutorial (https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/).

There is this:
The CheckAndRequest method can only be called from an Activity.
There is another method named Check that only tests whether the permission has already been approved or not. This method can be called from any module.
It might be tempting to first test whether there is a permission and only if there is no permission call CheckAndRequest. However it will just make the program flow more complicated as you will need to deal with all cases anyway.
As a general rule, you shouldn't call RuntimePermissions.Check from an Activity. It will be simpler to always call CheckAndRequest.

It doesn't say not to use Check, but it sounds like it might be easier not to.

- Colin
 
Upvote 0

ovasquez

Member
Licensed User
Longtime User
Thanks, I'm going to review the information you provided. I'm temporarily using targetSdkVersion = "22" and so it works correctly
:)
 
Upvote 0
Top