Why is my Android app icon not displayed correctly in the notification panel?

Kim Strasser 1,321 Reputation points
2023-03-14T19:38:32.9233333+00:00

I have created png images in different sizes on Android. When a push notification pops up in the upper part of the display then the app icon is displayed correctly, but when I open the notification panel on my Samsung tablet then the app icon is displayed differently. In the notification panel my app icon is a square in the center of a white circle and there is much white space around my square app icon and my app icon looks small because there is so much white space around it.

I have no picture of my notification panel but my notification panel looks similar to this one:

images

I have the following icon folders in the Resources folder in my Android project:

mipmap-hdpi

-->Icon.png 72x72

mipmap-ldpi

-->Icon.png 36x36

mipmap-mdpi

-->Icon.png 48x48

mipmap-xhdpi

-->Icon.png 96x96

mipmap-xxhdpi

-->Icon.png 144x144

mipmap-xxxhdpi

-->Icon.png 192x192

I use the following code to display push notifications:

void SendNotification(string messageBody, string Title, string messageSound, IDictionary<string, string> data)
{
            var intent = new Intent(this, typeof(Activity1));
            intent.AddFlags(ActivityFlags.ClearTop);
            foreach (var key in data.Keys)
            {
                intent.PutExtra(key, data[key]);
            }

            var pendingIntent = PendingIntent.GetActivity(this, Activity1.NOTIFICATION_ID, intent, PendingIntentFlags.Immutable);

            var notificationBuilder = new NotificationCompat.Builder(this, Activity1.CHANNEL_ID)
                                      .SetSmallIcon(Resource.Mipmap.Icon)
                                      .SetContentTitle(Title)
                                      .SetContentText(messageBody)
                                      .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                                      .SetVibrate(new long[] { 1000, 1000, 0, 0, 0 })
                                      .SetLights(Android.Graphics.Color.Red, 3000, 3000)
                                      .SetPriority((int)NotificationPriority.High)
                                      .SetAutoCancel(true)
                                      .SetContentIntent(pendingIntent);

            var notificationManager = NotificationManagerCompat.From(this);
            notificationManager.Notify(Activity1.NOTIFICATION_ID, notificationBuilder.Build());
}

Why is my Android app icon not displayed correctly in the notification panel? Is it necessary to create another app icon for the notification panel?

Developer technologies | .NET | .NET MAUI
Developer technologies | C#
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.