CarNotificationManager

public final class CarNotificationManager
extends Object

java.lang.Object
   ↳ androidx.car.app.notification.CarNotificationManager


A manager for car apps to send notifications. This class wraps a NotificationManagerCompat to manage the actual sending of the Notification.

Summary

Public methods

boolean areNotificationsEnabled()

Returns whether notifications from the calling package are not blocked.

void cancel(String tag, int id)

Cancels a previously shown notification.

void cancel(int id)

Cancels a previously shown notification.

void cancelAll()

Cancels all previously shown notifications.

void createNotificationChannel(NotificationChannelCompat channel)

Creates a notification channel that notifications can be posted to.

void createNotificationChannelGroup(NotificationChannelGroupCompat group)

Creates a group container for NotificationChannel objects.

void createNotificationChannelGroups(List<NotificationChannelGroupCompat> groups)

Creates multiple notification channel groups.

void createNotificationChannels(List<NotificationChannelCompat> channels)

Creates multiple notification channels that different notifications can be posted to.

void deleteNotificationChannel(String channelId)

Deletes the given notification channel.

void deleteNotificationChannelGroup(String groupId)

Deletes the given notification channel group, and all notification channels that belong to it.

void deleteUnlistedNotificationChannels(Collection<String> channelIds)

Deletes notification channels for which ids are NOT given.

static CarNotificationManager from(Context context)

Returns a CarNotificationManager instance for a provided context.

static Set<String> getEnabledListenerPackages(Context context)

Get the set of packages that have an enabled notification listener component within them.

int getImportance()

Returns the user specified importance for notifications from the calling package.

NotificationChannelCompat getNotificationChannel(String channelId)

Returns the notification channel settings for a given channel id.

NotificationChannelCompat getNotificationChannel(String channelId, String conversationId)

Returns the notification channel settings for a given channel and conversation id.

NotificationChannelGroupCompat getNotificationChannelGroup(String channelGroupId)

Returns the notification channel group settings for a given channel group id.

List<NotificationChannelGroupCompat> getNotificationChannelGroups()

Returns all notification channel groups belonging to the calling app or an empty list on older SDKs which don't support Notification Channels.

List<NotificationChannelCompat> getNotificationChannels()

Returns all notification channels belonging to the calling app or an empty list on older SDKs which don't support Notification Channels.

void notify(String tag, int id, NotificationCompat.Builder notification)

Post a notification to be shown in the status bar, stream, etc.

void notify(int id, NotificationCompat.Builder notification)

Posts a notification.

Inherited methods

Public methods

areNotificationsEnabled

public boolean areNotificationsEnabled ()

Returns whether notifications from the calling package are not blocked.

Returns
boolean

cancel

public void cancel (String tag, 
                int id)

Cancels a previously shown notification.

Parameters
tag String

id int

cancel

public void cancel (int id)

Cancels a previously shown notification.

Parameters
id int

cancelAll

public void cancelAll ()

Cancels all previously shown notifications.

createNotificationChannel

public void createNotificationChannel (NotificationChannelCompat channel)

Creates a notification channel that notifications can be posted to.