Class NotificationUtil
- java.lang.Object
-
- com.google.android.exoplayer2.util.NotificationUtil
-
public final class NotificationUtil extends Object
Utility methods for displayingNotifications.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceNotificationUtil.ImportanceNotification channel importance levels.
-
Field Summary
Fields Modifier and Type Field Description static intIMPORTANCE_DEFAULTstatic intIMPORTANCE_HIGHstatic intIMPORTANCE_LOWstatic intIMPORTANCE_MINstatic intIMPORTANCE_NONEstatic intIMPORTANCE_UNSPECIFIED
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcreateNotificationChannel(Context context, String id, int nameResourceId, int descriptionResourceId, int importance)Creates a notification channel that notifications can be posted to.static voidsetNotification(Context context, int id, Notification notification)Post a notification to be shown in the status bar.
-
-
-
Field Detail
-
IMPORTANCE_UNSPECIFIED
public static final int IMPORTANCE_UNSPECIFIED
-
IMPORTANCE_NONE
public static final int IMPORTANCE_NONE
-
IMPORTANCE_MIN
public static final int IMPORTANCE_MIN
-
IMPORTANCE_LOW
public static final int IMPORTANCE_LOW
-
IMPORTANCE_DEFAULT
public static final int IMPORTANCE_DEFAULT
-
IMPORTANCE_HIGH
public static final int IMPORTANCE_HIGH
-
-
Method Detail
-
createNotificationChannel
public static void createNotificationChannel(Context context, String id, @StringRes int nameResourceId, @StringRes int descriptionResourceId, @Importance int importance)
Creates a notification channel that notifications can be posted to. SeeNotificationChannelandNotificationManager.createNotificationChannel(NotificationChannel)for details.- Parameters:
context- AContext.id- The id of the channel. Must be unique per package. The value may be truncated if it's too long.nameResourceId- A string resource identifier for the user visible name of the channel. The recommended maximum length is 40 characters. The string may be truncated if it's too long. You can rename the channel when the system locale changes by listening for theIntent.ACTION_LOCALE_CHANGEDbroadcast.descriptionResourceId- A string resource identifier for the user visible description of the channel, or 0 if no description is provided. The recommended maximum length is 300 characters. The value may be truncated if it is too long. You can change the description of the channel when the system locale changes by listening for theIntent.ACTION_LOCALE_CHANGEDbroadcast.importance- The importance of the channel. This controls how interruptive notifications posted to this channel are. One ofIMPORTANCE_UNSPECIFIED,IMPORTANCE_NONE,IMPORTANCE_MIN,IMPORTANCE_LOW,IMPORTANCE_DEFAULTandIMPORTANCE_HIGH.
-
setNotification
public static void setNotification(Context context, int id, @Nullable Notification notification)
Post a notification to be shown in the status bar. If a notification with the same id has already been posted by your application and has not yet been canceled, it will be replaced by the updated information. Ifnotificationisnullthen any notification previously shown with the specified id will be cancelled.- Parameters:
context- AContext.id- The notification id.notification- TheNotificationto post, ornullto cancel a previously shown notification.
-
-