我尝试使用Android Oreo(SDK 27)处理通知。
以下是我创建NotificationChannel的代码:
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
// .. building mChannel, the NotificationChannel instance
notificationManager.createNotificationChannel(mChannel);
Android Studio告诉您
Error:(67, 32) error: cannot find symbol method createNotificationChannel(NotificationChannel)
我依赖support-compat:27.0.0设置到我的core / build.gradle文件中:
compile 'com.android.support:support-compat:27.0.0'
答案 0 :(得分:13)
createNotificationChannel()
上没有NotificationManagerCompat
方法。您必须使用原生NotificationManager
。