问题描述
NotificationManagerCompat.areNotificationsEnabled()
如何工作?我尝试执行以下操作 appPushEnabled = String.valueOf(NotificationManagerCompat.areNotificationsEnabled());
但是它给了我一个错误?
How does NotificationManagerCompat.areNotificationsEnabled()
work? I have tried to do the following appPushEnabled = String.valueOf(NotificationManagerCompat.areNotificationsEnabled());
however it is giving me an error?
还说它只适用于某些设备,我需要尝试一下吗?
Also it says it only works on some devices do I need a try catch on it?
推荐答案
经过几个小时的测试,这是我发现的.
After testing for few hours, here is what I have found.
在 App Gradle 文件中,com.android.support:support 应至少为 24,compileSdkVersion 必须为 24
In App Gradle file, com.android.support:support should be minimum 24 and compileSdkVersion has to be 24
android {
compileSdkVersion 24
}
dependencies {
compile 'com.android.support:support-v4:24.0.0'
}
然后@petey 的答案将起作用
And then @petey 's answer will be working
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
boolean areNotificationsEnabled = notificationManagerCompat.areNotificationsEnabled();
这篇关于android NotificationManagerCompat.areNotificationsEnabled 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!