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.
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'
}
And then @petey 's answer will be working
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
boolean areNotificationsEnabled = notificationManagerCompat.areNotificationsEnabled();
Try using NotificationManagerCompat.from(Context context) method to get an instance of a NotificationManagerCompat object you may then be able to call areNotificationsEnabled()
on.
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context)
boolean areNotificationsEnabled = notificationManagerCompat.areNotificationsEnabled();
String appPushEnabled = String.valueOf(areNotificationsEnabled);
You should set your gradle with
compile "com.android.support:support-v4:24.0.0"
minimum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With