Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clicking Android Notification Actions does not close Notification drawer

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?

like image 342
Aster Avatar asked Aug 15 '13 21:08

Aster


People also ask

How do I swipe away notifications on Android?

First, press-and-hold on the persistent notification you want to remove. Another option is to swipe the notification left or right, and then tap on the cogwheel icon shown next to it. Next, tap on the switch next to Permanent to disable it, and then press Save.


1 Answers

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.

like image 115
Andro Id Avatar answered Sep 21 '22 12:09

Andro Id