Charor
Charor

Reputation: 94

App uses the Launcher Icon as Notification Icon on some phones

I am testing my app on some phones.

When testing on LG, Samsung, and Kodak phones, (ranging from Android 5 to 7)the icon was the one I picked for notifications, a map like icon. Correct icon However, on all Huawei and a Xiaomi device I tried it on(also many OSs), the notification icon that appeared was the launcher icon, which at the time was an Android robot Wrong Icon

I used the built-in image asset studio to create the icon, following these instructions https://developer.android.com/studio/write/image-asset-studio.html#create-notification The code for the notification is here:

    public void crenot(float walk){
    Notification noti  = new Notification.Builder(this)
        .setContentTitle("Your daily result ")
        .setContentText("You walked "+Float.toString(walk/1000)+" km today")
        .setSmallIcon(R.drawable.map_not)
        .build();
    NotificationManager notman=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notman.notify(0,noti);}

I can't find a solution on google. I found this, Android notification displays wrong icon but I am not sure how I should change my code

Upvotes: 1

Views: 2523

Answers (1)

Diego D.
Diego D.

Reputation: 398

setSmallIcon() is used to set the icon in the status bar as said in the documentation.

If you want to set the icon in the notification drawer, add setLargeIcon() to your Notification.Builder:

.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.map_not))

Upvotes: 1

Related Questions