如何抑制可穿戴设备的打开手机"操作?我添加了一个更有用的自定义操作,现在是双重操作.知道如何删除它吗?
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.
更多推荐
隐藏可穿戴设备上的打开手机操作
发布评论