【问题标题】:Showing notifications on Motorola Active Display在 Motorola Active Display 上显示通知
【发布时间】:2016-04-02 11:07:36
【问题描述】:

我正在寻找如何在 Motorola X 样式或其他具有 Active Display 功能的设备上显示通知的方法。

我已经阅读了整个互联网,两次。没有结果。 默认通知未显示在活动显示器上。 我的基本想法是使用 Wea​​rableExtender 类扩展 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


【解决方案1】:

您的小图标必须是位图,而不是矢量图形。

【讨论】:

  • 我得到了 xxhdpi 大小为 72x72 的位图。问题一定出在其他地方。
【解决方案2】:

有时我真的很讨厌安卓。 2天后,我得到了解决方案。

解决方法很简单,你必须调用:

.setGroupSummary(true)

通知终于出现了。

【讨论】:

  • 记得将大图标位图调整为 128x128(如果您使用 setLargeIcon),否则 Active Display 不会显示图片。
猜你喜欢
  • 2021-09-29
  • 2014-11-05
  • 1970-01-01
  • 2013-06-20
  • 1970-01-01
  • 2018-12-23
  • 1970-01-01
  • 1970-01-01
  • 2020-09-07
相关资源
最近更新 更多