Clicking Android Notification Actions does not close Notification drawer

Aster picture Aster · Aug 15, 2013 · Viewed 17.4k times · Source

I am adding a Notification to System bar using the NotificationCompat library. This Notification has two action buttons. Also, AutoCancel() property on the Notification is set to true.

On Click of the action buttons, System is configured to launch an IntentService which calls NotificationManager.cancel(NOTIFICATION_ID) and then launches an Activity in a New Task.
Problem is that though this call removes the notification from the tray, it does not collapse the drawer. The called Activity is drawn behind the drawer.

Can someone please shed some light on what special code is need to close the draw apart from canceling the notification?

Answer

Andro Id picture Andro Id · Jun 10, 2014

If your action is in the form of a broadcast or a service but you intend for the notification drawer to collapse, you should broadcast android.intent.action.CLOSE_SYSTEM_DIALOGS from your onReceive. This will manually close the drawer.