How to set the app icon as the notification icon in the notification drawer

前端 未结 3 540
轮回少年
轮回少年 2020-12-01 07:51

As shown in the figure...
I am getting my notification icon(on left to the red colour).
But I need to display the app icon as shown by the black arrow

3条回答
  •  一向
    一向 (楼主)
    2020-12-01 08:19

    Try this code at your notification builder :

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
                    .setSmallIcon(R.mipmap.ic_launcher)
                    .setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
                            R.mipmap.ic_launcher))
                    .setContentTitle(title)
                    .setContentText(message)
                    .setAutoCancel(true)
                    .setSound(defaultSoundUri)
                    .setContentIntent(pendingIntent);
    
    android.app.NotificationManager notificationManager =
                    (android.app.NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    
    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
    

    Set Large icon does the trick.Comment below if you have any further info

提交回复
热议问题