How to find if user has enrolled any fingerprints

删除回忆录丶 提交于 2019-12-02 13:52:11

问题


I need to identify if the user has any fingerprint register on their device. However, I got an error using this line

  FingerprintManagerCompat  fpm = (FingerprintManagerCompat)CrossCurrentActivity.Current.Activity.GetSystemService(Context.FingerprintService);

``` error ``

{System.InvalidCastException: Specified cast is not valid.
  at app.Droid.lyA.FingerPrint.HasEnrolledFingerprints () [0x00002] in /../../../appmobile/../Droid/lyA/FingerPrint.cs:19 }

This is what I need to return.


回答1:


The correct way of using FingerprintManagerCompat is actually something like this:

FingerprintManagerCompat fpm= FingerprintManagerCompat.From(CrossCurrentActivity.Current.Activity);

Good luck!

Revert in case of queries.




回答2:


Converting my comment to an answer-

It seems that there is an error with the casting you did at

FingerprintManagerCompat fpm = (FingerprintManagerCompat)CrossCurrentActivity.Current.Activity.GetSystemService(Context.FingerprintService);

It seems that whatever is being returned here cannot be cast to FingerprintManagerCompat.

As mentioned in another answer, the correct way to use FingerprintManagerCompat is actually -

FingerprintManagerCompat fpm= FingerprintManagerCompat.From(this);

I would suggest changing to this and checking if it solves the issue.



来源:https://stackoverflow.com/questions/55521746/how-to-find-if-user-has-enrolled-any-fingerprints

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!