- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想知道我的应用是否可以显示通知。所以我找到了this .
所以我在使用 Eclipse 和 android:targetSdkVersion="24"的应用程序中使用了这个简单的功能
@TargetApi(24)
static boolean AreNotificationsEnabledForMyApp(Context myContext) {
if (Build.VERSION.SDK_INT < 24)
return true; //there is no way to know this in earlier Android releases so I return true.
NotificationManagerCompat nmc = NotificationManagerCompat.from(myContext);
return nmc.areNotificationsEnabled();
}
但是我得到一个编译错误
The method areNotificationsEnabled() is undefined for the type NotificationManagerCompat
最佳答案
您的代码有误。 areNotificationsEnabled()
自 support library ( docs ) 版本 24.0.0 起可用,不适用于 Android 平台。看起来您正在使用一些旧版本的库。在这种情况下,平台版本检查也没有用,可以安全地删除。
关于android - NotificationManagerCompat 类型未定义方法 areNotificationsEnabled(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43357419/
我想知道我的应用是否可以显示通知。所以我找到了this . 所以我在使用 Eclipse 和 android:targetSdkVersion="24"的应用程序中使用了这个简单的功能 @Targ
NotificationManagerCompat.areNotificationsEnabled() 是如何工作的?我尝试执行以下操作 appPushEnabled = String.valueOf
向后兼容性有什么作用 NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); 前提是
我可以这样创建通知: NotificationManager notificationManager = (NotificationManager) getSystemService(Context
我对可穿戴通知的文档有点困惑。 如果我现有的应用程序正在使用 Notification.Builder 和 NotificationManager.notify(),通知是否也会自动显示在配对的可穿戴
有没有办法在使用 NotificationManagerCompat 和 NotificationCompat 时在 Android Oreo 上设置 channel ? 最佳答案 由于 Notifi
在扩展 JobService 的 Java 类中使用 NotificationManagerCompat,出现“无法解析”错误。执行了“无效并重新启动”但没有任何反应。 这是我的代码: import
使用 NotificationManagerCompat 取消所有通知。 NotificationManagerCompat manager = NotificationManagerCom
我正在尝试在 fragment 中初始化NotificationManagerCompat,但显然我不能这样做,因为它需要在 Activity 中初始化。这是当我尝试在 fragment 中执行此操作
有人知道如何使用 Notification 和 PendingIntent 打开 Play Store 吗? I want to open Play Store with my app's page.
我有一个具有以下导入的项目类: import android.app.Activity; import android.app.Fragment; import android.app.Notific
我是一名优秀的程序员,十分优秀!