gpt4 book ai didi

android - 找不到方法 createNotificationChannel(NotificationChannel)

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:57:00 27 4
gpt4 key购买 nike

我正在尝试使用 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)

我在 core/build.gradle 文件中设置了对 support-compat:27.0.0 的依赖:

compile 'com.android.support:support-compat:27.0.0'

最佳答案

NotificationManagerCompat 上没有createNotificationChannel() 方法。为此,您必须使用 native NotificationManager

更新 2019-07-29:作为 Onkar Nene points out ,他们最终在 NotificationManagerCompat 上添加了 createNotificationChannel()。使用 androidx.appcompat:appcompat:1.1.0-rc01 或更新版本。

关于android - 找不到方法 createNotificationChannel(NotificationChannel),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48231793/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com