How to identify if device has in-display Biometric fingerprint support?
Faced with the same problem some time ago - OnePlus 6T has no Biometric UI, at the same time Samsung A51 - has its own (custom) UI for Fingerprint API and another for BiometricPrompt API.I tried to watch for Activity window focus loss (For OnePlus - activity do not lose focus, at the same time BiometricPrompt UI leads to focus loss), but appear a problem with the Samsung device.
The only solution that I found, and it works for now:
- Need to get the correct device name (for OnePlus for example, it should be not ONEPLUS A6003, but One Plus 6 instead)
- Need to perform request to
https://m.gsmarena.com/res.php3?sSearch=Device+Name
, you should get the list with matches, usually, first one is needed - Parse HTML (from previews step) to get the link for device specification (like
https://m.gsmarena.com/oneplus_6t-9350.php
) - Now you need to perform a request to this link and again parse HTML and get the "Sensors" section. You should get a string like "Fingerprint (under display, optical), accelerometer, gyro, proximity, compass"
- Split this string to get the list with sensors
- Now when you need to check if an in-display scanner is present on the device, just check for "fingerprint" and "under display" for the same sensor.
Link with impl. that can be used as an example
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { //Fingerprint API only available on from Android 6.0 (M) FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE); if (!fingerprintManager.isHardwareDetected()) { // Device doesn't support fingerprint authentication } else if (!fingerprintManager.hasEnrolledFingerprints()) { // User hasn't enrolled any fingerprints to authenticate with } else { // Everything is ready for fingerprint authentication }}
Dont Forget to Add
<uses-permission android:name=" android.permission.USE_BIOMETRIC" />