Android Question Runtime permisions fail to open dialog event

hookshy

Well-Known Member
Licensed User
I receive a lot of crashes on activity resume security.exception
Wait untile october then panic :mad::(:(

I go to app settings allow permistions to the app , then the app runs without any problem ....
I just updated some sdk from sdk manager , using android 25 platform, updated the b4a ...
last time i have updated this app to target skd 26 ..it worked ...I am lost do not know from where to start


B4X:
** Activity (main) Create, isFirst = true **
limbarom
limba setata este :rom
notitetest
Logger connected to:  HUAWEI PRA-LX1
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
limbarom
limba setata este :rom
notitetest
** Activity (main) Resume **
main_activity_resume (java line: 4212)
java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider uri content://sms from pid=6657, uid=10461 requires android.permission.READ_SMS, or grantUriPermission()
    at android.os.Parcel.readException(Parcel.java:1665)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
    at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
    at android.content.ContentResolver.query(ContentResolver.java:541)
    at android.content.ContentResolver.query(ContentResolver.java:476)
    at anywheresoftware.b4a.phone.SmsWrapper.get(SmsWrapper.java:85)
    at anywheresoftware.b4a.phone.SmsWrapper.GetByType(SmsWrapper.java:43)
    at com.hsw.voice_lite.main._activity_resume(main.java:4212)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at com.hsw.voice_lite.main.afterFirstLayout(main.java:110)
    at com.hsw.voice_lite.main.access$000(main.java:17)
    at com.hsw.voice_lite.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:761)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:156)
    at android.app.ActivityThread.main(ActivityThread.java:6523)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
 

hookshy

Well-Known Member
Licensed User
Here are the permisions that I ask for in activity resume

B4X:
Sub Activity_Resume ' good practice work with files in activity resume



    rp.CheckAndRequest(rp.PERMISSION_READ_SMS)
    rp.CheckAndRequest(rp.PERMISSION_READ_CONTACTS)
    rp.CheckAndRequest(rp.PERMISSION_RECEIVE_SMS)
    rp.CheckAndRequest(rp.PERMISSION_RECORD_AUDIO)
    rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
    rp.CheckAndRequest(rp.PERMISSION_READ_CALL_LOG)

    rp.CheckAndRequest(rp.PERMISSION_ACCESS_COARSE_LOCATION)
    rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE)
    rp.CheckAndRequest(rp.PERMISSION_SEND_SMS)
 

hookshy

Well-Known Member
Licensed User
I do not understand what is goning on ...now It works and I can not reproduce the actions that I have been through :mad:
A lot of trouble with all these changes ....
 

hookshy

Well-Known Member
Licensed User
Stupid permisions ...what the hell if you do not allow the app will not work ... now have to search for crashes when the user denies permitions...because they are afraid of digital thiefs

I even seen developer ...ask before ..please please allow permitions to this app
 

hookshy

Well-Known Member
Licensed User
32 users reporting today same problem

B4X:
Azi, 20:30 în versiunea 64 a aplicației
Leagoo KIICAA POWER (KIICAA_POWER), Android 7.0
Raportul 1

java.lang.SecurityException:
  at android.os.Parcel.readException (Parcel.java:1683)
  at android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:188)
  at android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:140)
  at android.content.ContentProviderProxy.query (ContentProviderNative.java:421)
  at android.content.ContentResolver.query (ContentResolver.java:537)
  at android.content.ContentResolver.query (ContentResolver.java:479)
  at anywheresoftware.b4a.phone.SmsWrapper.get (SmsWrapper.java:85)
  at anywheresoftware.b4a.phone.SmsWrapper.GetByType (SmsWrapper.java:43)
  at com.hsw.voice_lite.main._activity_resume (main.java:4212)
  at java.lang.reflect.Method.invoke (Native Method)
  at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:191)
  at anywheresoftware.b4a.BA.raiseEvent (BA.java:171)
  at com.hsw.voice_lite.main.afterFirstLayout (main.java:110)
  at com.hsw.voice_lite.main.access$000 (main.java:17)
  at com.hsw.voice_lite.main$WaitForLayout.run (main.java:82)
  at android.os.Handler.handleCallback (Handler.java:836)
  at android.os.Handler.dispatchMessage (Handler.java:103)
  at android.os.Looper.loop (Looper.java:203)
  at android.app.ActivityThread.main (ActivityThread.java:6259)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1063)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:924)
 

Peter Simpson

Expert
Licensed User
@hookshy have you added all the relevant permissions in the Manifest?

I always make sure that I've added all the relevant lines in the manifest file too.
B4X:
AddPermission(android.permission................)
You can tidy up all those RP's with something like this
B4X:
'Try this
   For Each RTPermission As String In Array (RP.PERMISSION_READ_SMS, RP.PERMISSION_READ_CONTACTS, RP.PERMISSION_RECEIVE_SMS, RP.PERMISSION_RECORD_AUDIO, _
        RP.PERMISSION_CALL_PHONE, RP.PERMISSION_READ_CALL_LOG, RP.PERMISSION_ACCESS_COARSE_LOCATION, RP.PERMISSION_READ_PHONE_STATE, RP.PERMISSION_SEND_SMS)
        RP.CheckAndRequest(RTPermission)
        Wait For Activity_PermissionResult (permission As String, Result As Boolean)
        If Not(Result) Then
            ToastMessageShow($"${permission} not granted..."$, True)
        Else
            Log($"${permission} is granted..."$)
        End If
    Next
Enjoy...
 
Last edited:

Peter Simpson

Expert
Licensed User
Hmm, I'm not 100% sure about that @kisoft,
For example when using MLWiFi using target sdk 28, if I remove AddPermission(android.permission.ACCESS_COARSE_LOCATION) from the manifest, even though I have the
RP.PERMISSION_ACCESS_COARSE_LOCATION in the Main activity requesting for permission, MLWiFi will point blank refuse to work until I put AddPermission(android.permission.ACCESS_COARSE_LOCATION) back into the manifest, you can always try it yourself.

I was under the impression that any RTP requested in the the main module would be automatically added to the manifest, but MLWiFi and another library that I used crushed that theory for me. Give me some time to get back home and I'll PM you an example...

Anyway, I always add the manifest permission as a matter or course these days, just to be on the safe side, better safe than sorry wasting time trying to figure out why certain RTP isn't working ;)
 
Last edited:

Peter Simpson

Expert
Licensed User
1. In most cases you don't need to add any permission as the permissions are declared inside the libraries.
That may be in most cases but not all cases, so I just add them anyway to stop any confusions or unnecessary issues, which I've had a few times now.

I sent @kisoft an example via pm, he agreed that the example I sent did indeed need the addpermission adding to the manifest even thought I'm requesting it via RuntimePermissions in the main Activity_Create.
 

Erel

Administrator
Staff member
Licensed User
adding to the manifest even thought I'm requesting it via RuntimePermissions in the main Activity_Create.
A dialog will never appear for a permission not listed in the manifest file. What I meant is that in most cases you don't need to add the permissions yourself as they will be added for you.
 
Top