点击Android的通知操作不会关闭通知抽屉 [英] Clicking Android Notification Actions does not close Notification drawer

查看:162
本文介绍了点击Android的通知操作不会关闭通知抽屉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用的是 NotificationCompat 库添加一个通知系统吧。该通知有两个操作按钮。此外,在通知 AutoCancel()属性设置为true。

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.

在点击的操作按钮,系统配置为发动 IntentService 这就要求 NotificationManager.cancel(NOTIFICATION_ID),然后启动一个新任务的活动。
问题是,虽然这调用从托盘通知,就不会倒塌的抽屉里。被叫活动绘制所述抽屉的后面。

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.

可有人请阐明什么特殊的code是需要从取消通知除了关闭平局一些轻?

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

感谢你。

推荐答案

如果你的动作是在广播或服务的形式,但你打算在通知抽屉崩溃,你应该播出的 安卓.intent.action.CLOSE_SYSTEM_DIALOGS 从您的onReceive。这将手动关闭抽屉。

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.

这篇关于点击Android的通知操作不会关闭通知抽屉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆