Векторный значок в уведомлении по-прежнему белый, даже если задан красный векторный рисунок - PullRequest
0 голосов
/ 20 февраля 2020


Я пытаюсь разобраться с иконками уведомлений в adroid.
Значок импортируется как векторное изображение и выглядит следующим образом (фон прозрачный - это экран из Android Предварительный просмотр в студии):
enter image description here
это полный код уведомления:

     NotificationManager mNotificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel("CONN_APP",
                    "COMMUNICATION",
                    NotificationManager.IMPORTANCE_DEFAULT);
            channel.setDescription("NOTIFICATIONS OF COMMUNICATION");
            mNotificationManager.createNotificationChannel(channel);
        }
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext(), "YOUR_CHANNEL_ID")
                .setContentTitle(title)
                .setSmallIcon(R.drawable.ic_car_red)
                .setLargeIcon(getBitmapFromVectorDrawable(R.drawable.ic_car_red))
                .setContentText(message)
                .setAutoCancel(false)
                .setOngoing(true);
        mBuilder.mActions.clear();


        Intent intent = new Intent(getApplicationContext(), ActivityMain.class);
        PendingIntent pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        mBuilder.setContentIntent(pi);
        mNotificationManager.notify(0, mBuilder.build());

две самые важные строки:

.setSmallIcon(R.drawable.ic_car_red)
.setLargeIcon(getBitmapFromVectorDrawable(R.drawable.ic_car_red))

и эффект выглядит так, как показано ниже, я совершенно сбит с толку, потому что, если я устанавливаю маленькую иконку как png drawable, все работает. Что я пропустил?

enter image description here enter image description here

...