隐藏可穿戴设备上的打开手机操作

编程入门 行业动态 更新时间:2024-10-25 06:28:12
本文介绍了隐藏可穿戴设备上的打开手机操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何抑制可穿戴设备的打开手机"操作?我添加了一个更有用的自定义操作,现在是双重操作.知道如何删除它吗?

How can I supress the "open on phone" action on a wearable? I added a more helpful custom action which is now a dublicate action. Any idea how I can remove it?

这是我如何构建通知的一个片段:

Here is a snip it how I build the Notification:

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不需要,因此我需要创建单独的通知吗?

I know that I can create a second notification which is only visible on the wearable but that cannot be wanted by android that I need to create a seperate notification isn't it?

推荐答案

我结束了创建多个通知的过程.这是一个示例:

I ended in creating multiple notifications. Here is an example:

// for the wearable NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setContentTitle("Title") .setContentText("Message") .setSmallIcon(R.drawable.icon) .setContentIntent(openIntent) .setGroup("MyGroup") .setDeleteIntent(magic()); // since I don't set setGroupSummary(true) this // notification will not been display on a mobile NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender(); extender.addAction(new NotificationCompat.Action.Builder(icon, "do something", openIntent).build()); builder.extend(extender); // fire it // for the mobile NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setContentTitle("Title") .setContentText("Message") .setSmallIcon(R.drawable.icon) .setContentIntent(openIntent) .setLocalOnly(true) // the magic to hide it on the wearable .setDeleteIntent(magic()); // fire it

使用magic()创建一个PendingIntent,它调用BroadcastReciever来隐藏其他通知以使其保持同步.

With magic() I create a PendingIntent which invokes a BroadcastReciever which hides the other notifications to keep them in sync.

更多推荐

隐藏可穿戴设备上的打开手机操作

本文发布于:2023-11-27 06:41:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636995.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:穿戴   操作   设备   手机

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!