gpt4 book ai didi

android - 无法解析方法 "checkSelfPermission"

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:29:48 25 4
gpt4 key购买 nike

我在下面的代码中收到错误:

 if (ContextCompat.checkSelfPermission(this,Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
}

“checkSelfPermission”始终为红色,表示存在某种错误。

我已经导入了“import android.support.v4.content.ContextCompat;”已经。

下面是我的build.gradle内容:

apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
applicationId "com.xyz.user.abc"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// testCompile 'junit:junit:4.12'
compile files('libs/volley.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.android.support:design:25.3.0'
compile 'junit:junit:4.12'
// compile 'com.google.android.gms:play-services-appindexing:10.2.1'
// compile 'com.google.android.gms:play-services:9.8.0'
// compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.android.support:support-v4:25.3.0'
compile files('libs/android-support-v4.jar')
}

任何建议将不胜感激。

我不知道为什么这不起作用。有点菜鸟。

最佳答案

使用 PermissionChecker.checkSelfPermission 而不是 ContextCompat.checkSelfPermission 可以更正上述错误。

关于android - 无法解析方法 "checkSelfPermission",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43172519/

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