The notification channels which introduced from Android O (API 26) version.I read about it from the following links:
- Managing notification channels
- Google Sample for Creating Channel
Questions:
If I have multiple numbers of notification then Is it a good idea to create notification channels when the application starts and keep it at
ApplicationScope
?public void addNotificationChannels(Context context) { List<NotificationChannel> 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); }
What will happen if I try to execute this line
new Notification.Builder(getApplicationContext(), PRIMARY_CHANNEL)
before adding channels to the notification manager