Tom*_*uhn 7 android fingerprint
两种方法都是硬件检测()和hasEnrolledFingerprints()始终返回false.我发现目标API 24工作正常,所以这只是25的问题.我想使用最新的API,但没有工作指纹是不可能的.
活动
FingerprintManagerCompat from = FingerprintManagerCompat.from(getApplication());
boolean hardwareDetected = from.isHardwareDetected();
boolean b = from.hasEnrolledFingerprints();
Run Code Online (Sandbox Code Playgroud)
app.gradle
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.tkuhn.myapplication"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)
充分利用FingerprintManager&FingerprintManagerCompat。
使用FingerprintManagerCompat的isHardwareDetected用于旧设备和FingerprintManager的isHardwareDetected新设备。
private boolean isSensorAvialable() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return ActivityCompat.checkSelfPermission(AppContext, Manifest.permission.USE_FINGERPRINT) == PackageManager.PERMISSION_GRANTED &&
AppContext.getSystemService(FingerprintManager.class).isHardwareDetected();
} else {
return FingerprintManagerCompat.from(AppContext).isHardwareDetected();
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
新支持库的问题来自于他们现在正在积极检查要包括的设备系统功能FEATURE_FINGERPRINT.看起来受影响的设备即使具有指纹传感器也没有在其配置中指定此功能.这是设备制造商方面的错误.
这是FingerprintManagerCompat将返回的签入false
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) { /**/ }
Run Code Online (Sandbox Code Playgroud)
您可以尝试使用Reprint或RxFingerpring作为替代解决方案.
FingerprintManager manager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
if (manager.isHardwareDetected()) {
//code here
}
Run Code Online (Sandbox Code Playgroud)
希望这有帮助
| 归档时间: |
|
| 查看次数: |
4215 次 |
| 最近记录: |