禁用默认通知 android wear

Disable default notifications android wear

我有一个带有 WearableListenerService 的 Android Wear 应用程序,它在收到 DataMap 时显示自定义通知。我的 phone 上有一个应用程序可以将 DataMap 发送到可穿戴应用程序。此应用程序接收来自 Firebase 的通知,可穿戴设备也会显示这些通知。我只希望 Wearable 显示我的自定义通知,而不是 phone 从它启动的地方。

谁能帮帮我?

谢谢。亲切的问候。

来自官方documentation:

By default, notifications are bridged (shared) from an app on a companion phone to the paired watch. If you build a standalone watch app and you have a companion phone app, the apps may duplicate notifications. The Android Wear includes features to handle this problem of duplicate notifications.

您需要将以下内容添加到应用的清单文件中:

<application>

    <meta-data
        android:name="com.google.android.wearable.notificationBridgeMode"
        android:value="NO_BRIDGING" />

</application>

或者您可以在代码中完成。有关详细信息,请参阅文档。