After upgrading my project to Android O
buildToolsVersion "26.0.1"
Lint in Android Studio is showing a deprecated warning for the follow notification builder method:
new NotificationCompat.Builder(context)
The problem is: Android Developers update their Documentation describing NotificationChannel to support notifications in Android O, and provide us with a snippet, yet with the same deprecated warning:
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();
Notifications Overview
My question: Is there is any other solution for building notification, and still support Android O?
A solution I found is to pass the channel ID as a parameter in Notification.Builder constructor. But this solution is not exactly reusable.
new Notification.Builder(MainActivity.this, "channel_id")
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…