Android Question Error with fingerprint manager - hardware detected

mc73

Well-Known Member
Licensed User
Longtime User
I got from an Android 4.4.2, this:
Code: Copy
Caused by java.lang.RuntimeException: Object should first be initialized (JavaObject).
       at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
       at anywheresoftware.b4j.object.JavaObject.getCurrentClass(JavaObject.java:258)
       at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:118)
and the b4a code line is
Code: Copy
Return sensor.RunMethod("isHardwareDetected", Null)
Perhaps we should use a "try-catch" block there?
 
A temporary fix, tested on a android 4, is:
Code: Copy
Public Sub getHardwareDetected As Boolean
   If sensor.IsInitialized Then  
   Return sensor.RunMethod("isHardwareDetected", Null)
   Else
       Return False
   End If  
End Sub
Hope there is a better approach.
 
Upvote 0
This class uses inline Java to access the fingerprint API introduced in Android 6.
It will only work on Android 6+ devices.

so you should use Phone Lib to check the SDK Version. Only use it with Android 6+ Devices.
 
Upvote 0
so you should use Phone Lib to check the SDK Version. Only use it with Android 6+ Devices.

I actually have a friend with a smartphone with fingerprint sensor, running android 5, and this class works great. Perhaps they give users a 'fix'.
Furthermore, I wouldn't want to use phone lib, some users find it sensitive, so for now, I'll just stack with the above workaround.
Thank you very much, Don, I always find your answers helpful.
 
Upvote 0
Furthermore, I wouldn't want to use phone lib, some users find it sensitive, so for now, I'll just stack with the above workaround.
Adding the Phone library to check the SdkVersion will not add any permission.

Permissions are only added when you declare a type that actually needs the permission.
 
Upvote 0
Adding the Phone library to check the SdkVersion will not add any permission.

Permissions are only added when you declare a type that actually needs the permission.
I see! Then, this is great and Don's suggestion will be followed!
But then, I miss some older devices which to my surprise react well to the fingreprint class :(
 
Upvote 0
It will be very surprising if FingerprintManager really works on an Android 5 devices. Maybe the phone was updated and actually runs Android 6.
I know but I've seen it with my own eyes earlier today! Tomorrow I'm going to check what really goes on with my friend's phone, perhaps you're absolutely right!
 
Upvote 0
Please report back
It's a Xiaomi device, see the attached screenshot. Everything works great. I'm pretty sure it received a patch for this.
However, I keep receiving random errors from devices running below api 23, so I guess I will follow your advice and remove support for these older devices.

Screenshot_2018-09-28-11-59-51-864_com.android.settings.png
 
Upvote 0
Back
Top