首页 > 解决方案 > Android 通知 setLargeIcon() 不起作用

问题描述

我正在使用 firebase 云消息推送通知,除了我的通知无法显示大图标外,一切都很好,我正在使用 144x144 像素和 1080x1080 的 @drawable/xxxx.PNG 图像,两者都经过测试,但仍然无法正常工作

这是我的代码

String CHANNEL_ID = "my_channel_01";
            CharSequence name = "my_channel";
            String Description = "This is my channel";
            int importance = NotificationManager.IMPORTANCE_HIGH;
            NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
            mChannel.setDescription(Description);
            mChannel.enableLights(true);
            mChannel.setLightColor(Color.RED);
            mChannel.enableVibration(true);
            mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
            mChannel.setShowBadge(false);
            notificationManager.createNotificationChannel(mChannel);
            Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.siublarge);
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
                    .setSmallIcon(R.mipmap.ic_launcher)
                    .setLargeIcon(largeIcon)
                    .setStyle(new NotificationCompat.BigTextStyle().bigText(message) )
                    .setContentText(message);

标签: androidandroid-studiofirebase-cloud-messaging

解决方案


推荐阅读