Search code examples
androidandroid-notificationsandroid-notification-bar

How to show image on the right hand side of the notification in android


I am working on android application . I need to create a notification for the app. I am able to create it successfully using :

http://www.tutorialspoint.com/android/android_notifications.htm

I know NotificationCompat.Builder setNumber(int Number) . It sets the number on the notification on the right hand side . But instead of the number i want to show a small icon. Do i need to use a custom layout , Because i am not able to find any API for this . How do i do it .


Solution

  • To show an image at the bottom right end of the notification, we have to use the following APIs

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(baseContext).setLargeIcon(large_icon)
                    .setSmallIcon(small_icon);
    

    For devices running up to android Kitkat the setLargeIcon sets the image at the left end, while the setSmallIcon sets the image at the bottom right end of the notification.

    For devices running on higher than Kitkat the setLargeIcon sets the image at the Left end, while the setSmallIcon sets the image at the bottom right end of the Large Image.