【发布时间】:2016-04-02 11:07:36
【问题描述】:
我正在寻找如何在 Motorola X 样式或其他具有 Active Display 功能的设备上显示通知的方法。
我已经阅读了整个互联网,两次。没有结果。 默认通知未显示在活动显示器上。 我的基本想法是使用 WearableExtender 类扩展 NotificationCompat。但是通知仍然只在托盘/锁屏中,而不是在活动显示中。
当前代码:
NotificationCompat.WearableExtender wearableExtender =
new NotificationCompat.WearableExtender().setHintHideIcon(true);
// Create notification
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
.setContentIntent(contentIntent)
.setSmallIcon(getSmallIconId(context, intent))
.setColor(context.getResources().getColor(R.color.primary))
.setGroup(group)
.setNumber(count)
.setContentTitle(title)
.setContentText(message)
.setOnlyAlertOnce(true)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
.setAutoCancel(true)
.setDefaults(NotificationCompat.DEFAULT_ALL)
.extend(wearableExtender);
// Show notification
NotificationManager mNotifyMgr =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotifyMgr.notify(id, notificationBuilder.build());
有人知道诀窍吗?
【问题讨论】:
-
我遇到了同样的问题,发现一些 cmets 应该使用
notificationBuilder.setVisibility()将可见性设置为公开。但这对我也没有帮助。
标签: android notifications lockscreen motorola