-1

Not able to change Icon in android studio using setsmallIcon in NotificationCompat.Builder

below is the code which i am trying and testing it on android 10


public class MyFirebaseMessagingService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        getFirebaseMessage(remoteMessage.getNotification().getTitle(), remoteMessage.getNotification().getBody());
    }

    public void getFirebaseMessage(String title, String msg){

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "myFirebaseChannel")
                .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher))
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(title)
                .setContentText(msg)
                .setAutoCancel(true);


        NotificationManagerCompat managerCompat = NotificationManagerCompat.from(this);

        managerCompat.notify(101, builder.build());
    }
}

2 Answers2

0

Try changing the icon size to 16x16 px and use only white colour because notification icons must be entirely white.

0

You need an icon size of 16x16px and use only white color, but this NotificationCompat.Builder that you are using would only help you in Application Live state, not killed state.

Rajiv Reddy
  • 339
  • 1
  • 11