Значок Android уведомления большой, есть ли способ удалить значок меньшего размера в правом нижнем углу?

У меня есть уведомление, которое отображает большой символ.

Есть ли способ удалить меньшую иконку из сотовых и выше устройств из этого представления?

Очевидно, что все еще сохраняется маленькая иконка для верхней строки состояния

enter image description here

   NotificationCompat.Builder builder = new NotificationCompat.Builder(context)


            // Set required fields, including the small icon, the
            // notification title, and text.
            .setSmallIcon(R.drawable.ic_notify_status_new)
            .setContentTitle(title)
            .setContentText(text)


            // All fields below this line are optional.

            // Use a default priority (recognized on devices running Android
            // 4.1 or later)
            .setPriority(NotificationCompat.PRIORITY_DEFAULT)

            // Provide a large icon, shown with the notification in the
            // notification drawer on devices running Android 3.0 or later.
            .setLargeIcon(picture)

            .setContentIntent(
                    PendingIntent.getActivity(
                            context,
                            0,
                            notiIntent,
                            PendingIntent.FLAG_UPDATE_CURRENT)
            );


    builder = getNotiSettings(builder);
    notify(context, builder.build());

Ответы

Ответ 1

Добавьте этот код после создания уведомления.

   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        int smallIconViewId = getResources().getIdentifier("right_icon", "id", android.R.class.getPackage().getName());

        if (smallIconViewId != 0) {
            if (notif.contentIntent != null)
                notif.contentView.setViewVisibility(smallIconViewId, View.INVISIBLE);

            if (notif.headsUpContentView != null)
                notif.headsUpContentView.setViewVisibility(smallIconViewId, View.INVISIBLE);

            if (notif.bigContentView != null)
                notif.bigContentView.setViewVisibility(smallIconViewId, View.INVISIBLE);
        }
    }

где "notif" - ваше построенное уведомление,

Ответ 2

Существует только один способ: Используйте свой собственный макет

Возможно, ваш вопрос является дубликатом NotificationCompat 4.1 SetSmallIcon и SetLargeIcon

Ответ 3

Используйте только setSmallIcon для вашего значка. Он также будет использоваться для largeIcon, если второй не был указан (просто убедитесь, что он достаточно большой, чтобы соответствовать обоим).

Убедитесь, что он хорошо выглядит на прелолипопе, лолипопе и выше. Например, здесь я устанавливаю значок приложения только для pre-lolipop устройств, где lolipop и выше получают разные smallIcon и такие же большиеIcon, как smallIcon.

int currentApiVersion = android.os.Build.VERSION.SDK_INT;
if (currentApiVersion >= Build.VERSION_CODES.LOLLIPOP) {
    notificationBuilder
        .setSmallIcon(smallIcon)
        .setLargeIcon(appIconDrawable)
} else {
    notificationBuilder.setSmallIcon(appIconDrawable);
}