0

Close the notification slider so i use this

val closeIntent = Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
applicationContext.sendBroadcast(closeIntent)

this code working on android 11 or lower.but it does not work in android 12.it through exception:

Permission Denial: android.intent.action.CLOSE_SYSTEM_DIALOGS
Muhammad Asad
  • 694
  • 6
  • 10
  • 1
    Does this answer your question? [How to dismiss notification since Android 12?](https://stackoverflow.com/questions/70926398/how-to-dismiss-notification-since-android-12) – Eugene Babich Aug 11 '22 at 10:41
  • ACTION_CLOSE_SYSTEM_DIALOGS is for system and preinstalled apps. Needs signature permission. – Milad Targholi Aug 11 '22 at 10:49

1 Answers1

1

If your app targets Android 12, you don't need to use ACTION_CLOSE_SYSTEM_DIALOGS in this situation. That's because, if your app calls startActivity() while a window is on top of the notification drawer, the system closes the notification drawer automatically.

Arda Kazancı
  • 8,341
  • 4
  • 28
  • 50
  • What you are saying might be true, but what if your activity already started, then this doesn't apply. I'm in the same situation, but I'm using it in case the window focus changed as I want to force the user staying inside my activity unless they are deactivating the kiosk mode using the pin code. – Billy Cottrell Nov 15 '22 at 16:14