gpt4 book ai didi

android - 隐藏可穿戴设备上的打开电话操作

转载 作者:太空宇宙 更新时间:2023-11-03 10:19:46 24 4
gpt4 key购买 nike

如何禁止可穿戴设备上的“在手机上打开”操作?我添加了一个更有用的自定义操作,它现在是一个重复操作。知道如何删除它吗?

这是我如何构建通知的 fragment :

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentTitle("Title")
.setContentText("Message")
.setSmallIcon(R.drawable.icon)
.setContentIntent(openIntent);
NotificationCompat.WearableExtender extender =
new NotificationCompat.WearableExtender();
extender.addAction(new NotificationCompat.Action.Builder(icon, "do something",
openIntent).build());
builder.extend(extender);

我知道我可以创建第二个通知,它只在可穿戴设备上可见,但 android 不希望我需要创建一个单独的通知,不是吗?

最佳答案

根据documentation当您在 setContentIntent(PendingIntent intent) 方法中设置任何 PendingIntent 时,“在手机上打开”操作会自动添加。

When this notification appears on a handheld device, the user can invoke the PendingIntent specified by the setContentIntent() method by touching the notification. When this notification appears on an Android wearable, the user can swipe the notification to the left to reveal the Open action, which invokes the intent on the handheld device.


我认为您不能“禁用”此操作(除了不指定 contentIntent 之外,但我想这不是适合您的解决方案)。

我不熟悉你的具体情况,但大多数人在通知上设置 contentIntent 以启动一些显示详细信息的 Activity 或允许用户做更多事情东西(如输入、配置等)。在这种情况下,我认为没有必要尝试禁用此额外操作,即使您正在 Android Wear 设备上提供某种“轻量级”解决方案也是如此。

但是如果您真的想摆脱这个“在手机上打开”操作(同时仍然在手机上设置了 contentIntent),您将需要从 Android Wear 设备发布单独的通知。

您将需要使用 DataApi 来同步您的通知状态。在文档中查看有关 DataApi 的更多详细信息:
https://developer.android.com/training/wearables/data-layer/index.html https://developer.android.com/training/wearables/data-layer/data-items.html

您还可以查看 DataApi 的用法示例 in one of my answers .

关于android - 隐藏可穿戴设备上的打开电话操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25864583/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com