My app creates a notification when some data is available. It has a button to copy that data to clipboard on the user's request. After doing so, the notification bar should close (without opening a new activity), so the user can paste the data they just copied into the app they were just using.
So far, I achieved this by sending sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
when the button was pressed, but targeting Android Sdk Version 31, this no longer is permitted (it says I need android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS
but even with this added to the manifest, I get the SecurityException).
I understand that "closing system dialogs" is nothing, that an app should do, but in my case the user clicked a notification which should dismiss the notification drawer. Is there a way to do this without the broadcast mentioned above?