【问题标题】:Is there a way to fire the action in a notification from notification service?有没有办法在通知服务的通知中触发操作?
【发布时间】:2015-02-19 11:38:41
【问题描述】:

我正在 Android 中编写通知服务,目前正在读取和关闭来自此通知服务的所有通知。

Bundle extras = mNotification.extras;

title = extras.getString(Notification.EXTRA_TITLE);
notificationLargeIcon = (Bitmap) extras
                        .getParcelable(Notification.EXTRA_LARGE_ICON);
smallContents = extras
                        .getCharSequence(Notification.EXTRA_TEXT);

为了回复通知,有没有办法触发“回复”操作?我可以访问通知操作,但我不确定如何从通知服务中触发操作。

Notification.Action[] actions = mNotification.actions;

【问题讨论】:

    标签: android android-intent notifications android-notifications


    【解决方案1】:

    如果通知是推送的,您可以在收到通知时回复(onMessage)。 如果是您的应用程序生成本地通知,那么您不应该生成它们就更清楚了。相反,您必须直接回复

    【讨论】:

    • 对不起,我没有关注你。我说的是 NotificationListenerService (developer.android.com/reference/android/service/notification/…),我正在尝试接收所有类型的通知(例如:环聊、Facebook、Whatsapp 和 viber 等)并在不打开应用程序的情况下从我的服务中回复。
    • 哦,对不起。您可以在一个操作中访问字段 actionIntent 吗?
    猜你喜欢
    • 2021-01-05
    • 2015-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-12
    • 1970-01-01
    相关资源
    最近更新 更多