Android Question Notification actions issue on targetSdkVersion 31

malaz

Member
Licensed User
Longtime User
Hi All

Hope you are doing well
I just need your kind support about the following recent issue start appearing when switiching to 31 sdk, so the app crachs when the user hit any notification Action button (NB6):

Error Message:
java.lang.SecurityException: Permission Denial: android.intent.action.CLOSE_SYSTEM_DIALOGS broadcast from com.test.cep (pid=13102, uid=10157) requires android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS.
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
    at android.os.Parcel.createException(Parcel.java:2995)
    at android.os.Parcel.readException(Parcel.java:2978)
    at android.os.Parcel.readException(Parcel.java:2920)
    at android.app.IActivityManager$Stub$Proxy.broadcastIntentWithFeature(IActivityManager.java:5096)
    at android.app.ContextImpl.sendBroadcast(ContextImpl.java:1193)
    at android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:500)
    at anywheresoftware.b4a.phone.Phone.SendBroadcastIntent(Phone.java:207)
    at com.test.cep.notificationsactions._service_start(notificationsactions.java:1488)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at com.test.cep.notificationsactions.handleStart(notificationsactions.java:100)
    at com.test.cep.notificationsactions.access$000(notificationsactions.java:8)
    at com.test.cep.notificationsactions$1.run(notificationsactions.java:71)
    at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand(ServiceHelper.java:237)

I read some article about that and all said that ACTION_CLOSE_SYSTEM_DIALOGS intent action is deprecated. is there any solution for still using this feature in my app?
B4A Version: 12.20
targetSdkVersion: 31

And many thanks in advance.
 
Last edited:

walterf25

Expert
Licensed User
Longtime User
Hi All

Hope you are doing well
I just need your kind support about the following recent issue start appearing when switiching to 31 sdk, so the app crachs when the user hit any notification Action button (NB6):

Error Message:
java.lang.SecurityException: Permission Denial: android.intent.action.CLOSE_SYSTEM_DIALOGS broadcast from com.test.cep (pid=13102, uid=10157) requires android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS.
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
    at android.os.Parcel.createException(Parcel.java:2995)
    at android.os.Parcel.readException(Parcel.java:2978)
    at android.os.Parcel.readException(Parcel.java:2920)
    at android.app.IActivityManager$Stub$Proxy.broadcastIntentWithFeature(IActivityManager.java:5096)
    at android.app.ContextImpl.sendBroadcast(ContextImpl.java:1193)
    at android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:500)
    at anywheresoftware.b4a.phone.Phone.SendBroadcastIntent(Phone.java:207)
    at com.test.cep.notificationsactions._service_start(notificationsactions.java:1488)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at com.test.cep.notificationsactions.handleStart(notificationsactions.java:100)
    at com.test.cep.notificationsactions.access$000(notificationsactions.java:8)
    at com.test.cep.notificationsactions$1.run(notificationsactions.java:71)
    at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand(ServiceHelper.java:237)

I read some article about that and all said that ACTION_CLOSE_SYSTEM_DIALOGS intent action is deprecated. is there any solution for still using this feature in my app?
B4A Version: 12.20
targetSdkVersion: 31

And many thanks in advance.
Are you using the code module or the library file?

see here

Walter
 
Upvote 0

malaz

Member
Licensed User
Longtime User
Hi brothers

The problem solved partially by checking sdk version when trying to close the notification drawer as following since on Android 12 and higher there is no need to close the dialog by yourself:

Solution:
    Dim p As Phone
    If p.SdkVersion <= 30 Then ' Android 11 and lower
        Dim intent As Intent
        intent.Initialize("android.intent.action.CLOSE_SYSTEM_DIALOGS", "") 'close the notifications drawer
        p.SendBroadcastIntent(intent)  
    End If

Thanks to all
 
Upvote 0
Top