android– 在可穿戴设备上隐藏打开电话 *** 作

android– 在可穿戴设备上隐藏打开电话 *** 作,第1张

概述如何在可穿戴设备上抑制“打开电话”动作?我添加了一个更有帮助的自定义 *** 作,现在是一个dublicate行动.知道如何删除它吗?这是我如何建立通知的一个剪辑:NotificationCompat.Builderbuilder=newNotificationCompat.Builder(context).setContentTitle("Title").setCon

如何在可穿戴设备上抑制“打开电话”动作?我添加了一个更有帮助的自定义 *** 作,现在是一个dublicate行动.知道如何删除它吗?

这是我如何建立通知的一个剪辑:

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);

我知道我可以创建第二个通知,这个通知只能在可穿戴设备上看到,但是我不需要知道我需要创建一个单独的通知不是吗?

解决方法:

根据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 – 在可穿戴设备上隐藏打开电话 *** 作全部内容,希望文章能够帮你解决android – 在可穿戴设备上隐藏打开电话 *** 作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1118029.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存