我正在尝试实施指纹扫描程序,我首先检查权限,以便我可以获得用户权限。
我有以下代码:
int permissionState = ContextCompat.checkSelfPermission(SecurityPicker.this, Manifest.permission.USE_FINGERPRINT);
Log.d("SecrityPicker", String.valueOf(Build.VERSION.SDK_INT));
if (ContextCompat.checkSelfPermission(SecurityPicker.this, Manifest.permission.USE_FINGERPRINT)
== PackageManager.PERMISSION_DENIED)
{
ActivityCompat.requestPermissions(SecurityPicker.this, new String[]{Manifest.permission.USE_FINGERPRINT},
MY_PERMISSION_USE_FINGERPRINT);
}
else
{
fingerPrintContainer.setVisibility(View.VISIBLE);
}
checkSelfPermission总是返回许可,即使我还没有。 Android模拟器我正在使用API 23(Marshmallow)。
以下是我的gradle文件
android {
compileSdkVersion 23
buildToolsVersion "24.0.0-rc1"
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 33
versionName "2.0.1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
}
}
repositories {
mavenLocal()
}
}