После обновления моего проекта до Android O
buildToolsVersion "26.0.1"
Lint в Android Studio показывает устаревшее предупреждение для следующего метода построения уведомлений:
new NotificationCompat.Builder(context)
Проблема заключается в том, что разработчики Android обновляют свою Документацию, описывая NotificationChannel, для поддержки уведомлений в Android O и предоставляют нам фрагмент кода, но с тем же самым устаревшим предупреждением:
Notification notification = new Notification.Builder(MainActivity.this)
.setContentTitle("New Message")
.setContentText("You've received new messages.")
.setSmallIcon(R.drawable.ic_notify_status)
.setChannelId(CHANNEL_ID)
.build();
Мой вопрос: есть ли какое-либо другое решение для создания уведомлений и по-прежнему поддерживать Android O?
Решение, которое я нашел, это передать идентификатор канала в качестве параметра в конструкторе Notification.Builder. Но это решение не может быть повторно использовано повторно.
new Notification.Builder(MainActivity.this, "channel_id")