Search code examples
androidandroidx

Must the Notifications style be the one of BigTextStyle, BigPictureStyle, InboxStyle and MessagingStyle?


I'm learning Notifications, I use Android Studio 4.0 with latest androidx.core.app.NotificationManagerCompat.

There is a sample code about Notifications in the project user-interface-samples.

I find there are many differents about Notifications between this androidx and previous API.

Must the Notifications style be the one of BigTextStyleNotification, BigPictureStyleNotification, InboxStyleNotification and MessagingStyleNotification ?


Solution

  • Following are the notification styles available :

    Notification.BigPictureStyle, Notification.BigTextStyle, Notification.DecoratedCustomViewStyle, Notification.InboxStyle, Notification.MediaStyle, Notification.MessagingStyle

    You can get more info on this link.

    Just for information purposes, to create a notification without hustle and get all predefined formatting in one place, just do the following :

    1. Go to the Project Tab of android studio and right click.
    2. Click on New -> UI Component -> Notification
    3. Enter the required notification name

    To call this notification just enter the following :

    <NotificationClassName>.createNotification(getApplicationContext());