How can I programmatically open/close notifications in Android?

user496854 picture user496854 · Feb 17, 2011 · Viewed 27.5k times · Source

I've searched everywhere, but can't find anything in the SDK or on Google on how to do this. I know it's possible because all the custom launchers are able to do it via a button press (LauncherPro, ADW, etc).

Thanks.

Answer

Christopher Orr picture Christopher Orr · Jul 31, 2015

You can programmatically close the notification drawer by broadcasting an ACTION_CLOSE_SYSTEM_DIALOGS intent.

This causes "temporary system dialogs" to be dismissed. From the documentation:

Some examples of temporary system dialogs are the notification window-shade and the recent tasks dialog.

This doesn't require any permissions, and has apparently been available since Android 1.0.

The following code works for me on a Nexus 4 running Android 5.0:

Intent closeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
context.sendBroadcast(closeIntent);