Значок уведомления Oreo FCM не отображается после закрытия приложения (полностью закрыто) - PullRequest
0 голосов
/ 18 сентября 2018

Android Oreo неправильно отображает значок уведомления в строке состояния и в самом уведомлении, когда приложение полностью закрыто (убито). Работает нормально, когда приложение открыто на переднем плане.

    int notificationId = new Random().nextInt(60000);

    PendingIntent contentIntent = PendingIntent.getActivity(ctx, notificationId + 1,
            intent, PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
        setupChannels();
    }
    String CHANNEL_ID = getString(R.string.default_notification_channel_id);

    Bitmap bitmap = null;
    if (imageUrl != null && !imageUrl.equalsIgnoreCase("")) {
        bitmap = getBitmapfromUrl(imageUrl);
    }
    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(ctx, CHANNEL_ID)
                    .setContentTitle(notificationTitle)
                    .setStyle(new NotificationCompat.BigPictureStyle()
                            .setSummaryText(notificationMsg)
                            .bigPicture(bitmap))/*Notification with Image*/
                    .setSound(defaultSoundUri)
                    .setContentText(msg)
                    .setChannelId(CHANNEL_ID)
                    .setAutoCancel(true)
                    .setContentIntent(contentIntent)
                    .setPriority(Notification.PRIORITY_HIGH);

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mBuilder.setColor(getResources().getColor(R.color.colorPrimaryDark));
    }

    mBuilder.setLargeIcon(BitmapFactory.decodeResource(ctx.getResources(), getNotificationIcon()));
    mBuilder.setSmallIcon(getNotificationIcon());

    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    mBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;

    private int getNotificationIcon() {
       boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O);
       return useWhiteIcon ? R.mipmap.ic_launcher_icon_round : R.mipmap.ic_launcher;
    }

Заранее спасибо ...

...