Подтвердить что ты не робот

Как установить значок приложения в качестве значка уведомления в ящике уведомлений

Как показано на рисунке...
Я получаю свой значок уведомления (слева от красного цвета).
Но мне нужно отобразить значок приложения, как показано черной стрелкой

введите описание изображения здесь

    public void notify(View view){
    notification.setSmallIcon(R.drawable.ic_stat_name);
    notification.setTicker("Welcome to ****");
    notification.setWhen(System.currentTimeMillis());
    notification.setContentTitle("abcd");
    notification.setContentText("abcd");


    Intent intent = new Intent(this, home.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    notification.setContentIntent(pendingIntent);


    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    nm.notify(uniqueID, notification.build());
}
4b9b3361

Ответ 1

Рекомендуется опубликовать свой код, чтобы мы могли его решить. В любом случае попробуйте этот код в своем построителе уведомлений:

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
                        R.mipmap.ic_launcher))
                .setContentTitle(title)
                .setContentText(message)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);

        android.app.NotificationManager notificationManager =
                (android.app.NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

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

Значок Set Large делает трюк. Нижеприведенный комментарий, если у вас есть дополнительная информация

Ответ 2

Я знаю, что он немного опоздал, чтобы ответить здесь, а также на его уже ответили, но я пришел сюда, чтобы найти легкое исправление с помощью уведомлений firebase. Кто-то, как я, посещающий здесь, может решить проблему с помощью рекомендуемого и простого способа уведомления о пожарной базе, который просто добавляет метаданные в манифест.

Ссылка

<!-- Set custom default icon. This is used when no icon is set for incoming notification messages. -->
<meta-data
    android:name="com.google.firebase.messaging.default_notification_icon"
    android:resource="@drawable/ic_stat_ic_notification" />
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming notification message. -->
<meta-data
    android:name="com.google.firebase.messaging.default_notification_color"
    android:resource="@color/colorAccent" />