Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show Small Icon in notification Bar but hide in notification Panel

I try to find this one in this forum and I found a couple but no one worked for me. I just need to hide it in the notification panel where appears next to the large icon but if I hide it, it also dissapears from the notification bar.

enter image description here

Is there any way to show only the large icon as is happening in the first and fourth notifications?
This is the code that I am using:

mNotificationManager = (NotificationManager)
            this.getSystemService(Context.NOTIFICATION_SERVICE);
    Intent intent;

    Notification.Builder mBuilder =
            new Notification.Builder(this)
                    .setSmallIcon(R.mipmap.small_icon).setTicker(getApplicationContext().getResources().getString(R.string.app_name))
                    .setLargeIcon(largeIcon)
                    .setAutoCancel(true)
                    .setVibrate(new long[]{1000, 1000, 1000, 1000, 1000})
                    .setLights(Color.GREEN, 1000, 1000)
                    .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                    .setContentTitle(extras.getString("title"))
                    .setStyle(new Notification.BigTextStyle().bigText(extras.getString("message")))
                    .setContentText(extras.getString("message"));
        edit.putString(Config.FRAGMENT, extras.getString("fragment"));
        edit.commit();
        intent = new Intent(this, NavigationActivity.class);
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                intent, 0);
        mBuilder.setContentIntent(contentIntent);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
like image 491
Iban Arriola Avatar asked Mar 12 '23 14:03

Iban Arriola


1 Answers

You can make it invisible after building the notification :

int smallIconId = context.getResources().getIdentifier("right_icon", "id", android.R.class.getPackage().getName());
            if (smallIconId != 0) {
                notification.contentView.setViewVisibility(smallIconId, View.INVISIBLE);
                notification.bigContentView.setViewVisibility(smallIconId, View.INVISIBLE);
            }
like image 192
awsleiman Avatar answered Apr 29 '23 01:04

awsleiman