简体   繁体   中英

Notification Icon Issue

Notification Icon is not appearing in redmi MI device,it appears the default ic_launcher while in every other devices image is appears.API 22 and Android 5.1.1 and minsdk=15,target=24.I had tested in many other mobiles there is no issue but in my device this issue is there.Can you please get rid out from this problem. my code is

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setSmallIcon(R.drawable.home1);  //icon appears in device notification bar and right hand corner of notification
    builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.home1));        
    builder.setContentIntent(pendingIntent);      
            builder.setContentTitle(Title);        
    builder.setContentText(message);        
    builder.setSubText(subtext);
    NotificationManager notificationManager = (NotificationManager) getSystemService(context.NOTIFICATION_SERVICE);        
    notificationManager.notify(NOTIFICATION_ID, builder.build()); 

Thank you in advance

please use two icon in your notification. first one is small white png so that it will show in status bar and second one is app logo.

Update white icon in below folder with difference size.

  1. hdpi (36x36)
  2. mdpi (24x24)
  3. xhdpi (48x48)

Suppose this image name is app_logo_white_small.png.

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setLargeIcon(
                    BitmapFactory.decodeResource(
                            getResources(), R.drawable.app_icon))
            .setSmallIcon(R.drawable.app_logo_white_small)
            .setContentTitle(mContext.getString(R.string.app_name))
            .setDefaults(Notification.DEFAULT_ALL)
            .setContentText(msg)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
            .setContentIntent(getPendingIntent())
            .setAutoCancel(true);
    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

 notificationManager.notify((int) System.currentTimeMillis(), notificationBuilder.build());

I hope, it will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM