Group notifications on a wearable from the micro app

穿精又带淫゛_ 提交于 2019-12-01 09:40:50

问题


I build a micro app for a wearable now I'm working with notifications on the device.

Here is my example code:

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
        .setContentTitle(title)
        .setContentText(message)
        .setSmallIcon(icon)
        .setGroup(groupKey);

NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(id, builder.build());

This notification is never shown and it does not matter if I have one or multiple notifications with the same group key. Do you know what I'm doing wrong?


Just for clarification I striped down my Activity to this:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setContentTitle("title")
            .setContentText("message")
            .setSmallIcon(R.drawable.ic_launcher)
            .setGroup("groupKey");
    notificationManager.notify(111, builder.build());

    builder = new NotificationCompat.Builder(this)
            .setContentTitle("title2")
            .setContentText("message2")
            .setSmallIcon(R.drawable.ic_launcher)
            .setGroup("groupKey");
    notificationManager.notify(222, builder.build());
}

If those .setGroup("groupKey") lines are inside the wearable app (on the wearable) no notifications are visible. If I remove them the notifications are visible (ungrouped of cause). That does not work for me on the Samsung Gear Live (Android 4.4W.1) and the emulator (Android 4.4W).

来源:https://stackoverflow.com/questions/25885364/group-notifications-on-a-wearable-from-the-micro-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!