appcompat-v7和NotificationManagerCompat的问题

时间:2017-02-13 10:49:58

标签: android

我正在尝试使用

NotificationManagerCompat.from(this).areNotificationsEnabled()

确定我的应用是否允许推送通知。但是它没有使用此错误进行编译:

error: cannot find symbol
Log.d(TAG, "Allowed PushNotes: " + NotificationManagerCompat.from(this).areNotificationsEnabled());
                                                                         ^
symbol:   method areNotificationsEnabled()
location: class NotificationManagerCompat

它是这样导入的:

import android.support.v4.app.NotificationManagerCompat;

这些是build.gradle的相关部分,我想:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.example"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 10
        versionName "1.9"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true        
    }

这就是依赖:

dependencies {
  compile "com.android.support:appcompat-v7:23.4.0"

2 个答案:

答案 0 :(得分:0)

编译“com.android.support:support-v4:24.0.0”

答案 1 :(得分:0)

在App Gradle文件中,com.android.support:support应至少为24 compileSdkVersion必须为24

android {
   compileSdkVersion 24

}

dependencies {
    compile 'com.android.support:support-v4:24.0.0'
}