Galaxy Watch(Tizen)上的通知不显示图标

发布于 2025-01-31 02:19:13 字数 1506 浏览 3 评论 0原文

我有简单的应用程序发送通知,我想在三星观看(Active 2)上显示。该通知本身已显示在手表上,但我无法显示图标。这是Gmail和我的应用程序的通知示例。在Gmail(左)上,您可以看到该应用的图标,而在右边,您无法看到。我想念什么?

notification-shown

我使用的相关代码如下:

    int notificationId = 001;
    Bitmap bIcon = BitmapFactory.decodeResource( getResources(),R.drawable.ic_stat_ic_notification);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId)
            .setSmallIcon(R.drawable.ic_stat_ic_notification)
            .setLargeIcon(bIcon)
            .setContentTitle(title)
            .setContentText(message)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationCompat.WearableExtender wearableExtender =
            new NotificationCompat.WearableExtender().setContentAction(0);

    notificationBuilder.extend(wearableExtender);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel channel = new NotificationChannel(channelId,
                "Home Notifier",  NotificationManager.IMPORTANCE_DEFAULT);
        notificationManager.createNotificationChannel(channel);
    }

    notificationManager.notify(notificationId /* ID of notification */, notificationBuilder.build());

I have simple application that sends notifications, which I want to show on Samsung Watch (Active 2). The notification itself is shown on watch, but I cannot get Icon to be displayed. Here is example of notification from gmail and from my app. On gmail (left) you can see icon of the app, while on the right you cannot. What am I missing?

notification-shown

Relevant code I use is below:

    int notificationId = 001;
    Bitmap bIcon = BitmapFactory.decodeResource( getResources(),R.drawable.ic_stat_ic_notification);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId)
            .setSmallIcon(R.drawable.ic_stat_ic_notification)
            .setLargeIcon(bIcon)
            .setContentTitle(title)
            .setContentText(message)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationCompat.WearableExtender wearableExtender =
            new NotificationCompat.WearableExtender().setContentAction(0);

    notificationBuilder.extend(wearableExtender);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel channel = new NotificationChannel(channelId,
                "Home Notifier",  NotificationManager.IMPORTANCE_DEFAULT);
        notificationManager.createNotificationChannel(channel);
    }

    notificationManager.notify(notificationId /* ID of notification */, notificationBuilder.build());

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文