Android notification icon is a white circle.

Today I have a strange problem with the notification icon.

It looks like this: enter image description here (white circle ...)

Did I do something bad?

Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.icon_notification)
                .setContentTitle(this.getString(R.string.notification_title))
                .setContentText(this.getString(R.string.notification_text))
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);

Here is my icon image (just downloaded here https://material.io/icons/#ic_photo ): http://image.noelshack.com/fichiers/2016/44/1478185219-icon-notification.png

Did I miss something?

For recording, I use SDK 24 and just created a resource folder hdpi.

Edit # 1: I added icons ldpi, mdpiand xhdpi, nothing has changed ...

Edit # 2: For more accuracy, I'm trying to create this notification from a service ... FCM Messaging Service ...

+4
5

, ... , , ( ), , somekind cache .

Windows : , Android sudio = > , .

+2

. Android .

.setColor(context.getResources().getColor(R.color.colorPrimary))

.

, , .

In Android Studio On the system panel On notification

+2

. - Android 20,

int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP){
        currentapiVersion=R.mipmap.ic_notification_lolipop;
} else{
        currentapiVersion=R.mipmap.ic_launcher;
}

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(currentapiVersion)......
0

U , . U .

https://romannurik.imtqy.com/AndroidAssetStudio/icons-notification.html#source.type=clipart&source.clipart=ac_unit&source.space.trim=1&source.space.pad=0&name=ic_stat_ac_unit

Note. You need to upload a PNG image of your icon with a transparent background.

U installation icon may have this method

private int getSmallIconForNotification(){
    return (Build.VERSION.SDK_INT>Build.VERSION_CODES.LOLLIPOP)? R.mipmap.ic_stat_launcher : R.mipmap.ic_launcher;
}

Code Usage:

private NotificationCompat.Builder createNotificationBuilder(){
    return new NotificationCompat.Builder(this)
            .setSmallIcon(getSmallIconForNotification())
            .setContentTitle("New Message")
            .setContentText("Hi there.....")
            .setAutoCancel(true);
}
0
source

Source: https://habr.com/ru/post/1659740/


All Articles