从
Android O(API 26)版本引入的通知渠道.我从以下链接中了解到它:
问题:
>如果我有多个通知,那么在应用程序启动时创建通知通道并将其保留在ApplicationScope是否是个好主意?
public void addNotificationChannels(Context context) {
List channels = new ArrayList<>();
channels.add("channel_1");
channels.add("channel_2");
.
.
channels.add("channel_7");
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannels(channels);
}
>如果我在向通知管理器添加通道之前尝试执行此行新Notification.Builder(getApplicationContext(),PRIMARY_CHANNEL)会发生什么