Can I override default push notification icon in android from app icon to custom icon?

后端 未结 6 936
遥遥无期
遥遥无期 2021-02-12 16:16

Can I override default push notification icon in android from app icon to custom icon?

I am using default firebase implementation to display notification in system tray,

6条回答
  •  遥遥无期
    2021-02-12 16:57

    Yes you can do it.If you want to avoid white circle icon you must make your icon transparent and add background color to it.So the color you use appears out through the transparent icon and makes the icon visible and colorful. please check for setSmallIcon and setColor in the below sample code.Check this doc and search for transparent

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                    context)
                    .setContentIntent(contentIntent)
                    .setSmallIcon(R.drawable.transaparentIcon)
                    .setColor(context.getResources().getColor(R.color.notif_color))
                    .setWhen(System.currentTimeMillis())
                    .setContentTitle(context.getString(R.string.app_name))
                    .setStyle(
                            new NotificationCompat.BigTextStyle()
                                    .bigText(notificationText))
                    .setContentText(notificationText)
                    .setAutoCancel(true);
    

提交回复
热议问题