FingerprintManager#isHardwareDetected()和FingerprintManager#hasEnrolledFingerprints()。两者均已在Android 28中弃用。 我还能使用什么来查看此版本中是否注册了指纹? 我认为这是一个选择。
KeyguardManager keyguardManager =
(KeyguardManager) getSystemService(KEYGUARD_SERVICE);
如果该选项还可以,如何将其转换为xamarin形式,例如()
FingerprintManagerCompat fpm= FingerprintManagerCompat.From(CrossCurrentActivity.Current.Activity);
对此:
答案 0 :(得分:0)
您可以使用Plugin.Fingerprint
在android 9.0中完成它。
https://www.nuget.org/packages/Plugin.Fingerprint/
有我的演示的GIF文件(如果您首次运行此项目,请确保已在设备中创建了指纹)。
由于表单只有一项活动,如果推送身份验证页面,我们应该实现ActivityLifecycleCallbacks
和FingerprintDialogFragment
这是 MainApplication 的代码,它需要Plugin.CurrentActivity
插件
[Application]
public class MainApplication : Application, Application.IActivityLifecycleCallbacks
{
public MainApplication(IntPtr handle, JniHandleOwnership transer)
: base(handle, transer)
{
}
public override void OnCreate()
{
base.OnCreate();
RegisterActivityLifecycleCallbacks(this);
CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);
// uncomment this line to use custom dialog
//CrossFingerprint.SetDialogFragmentType<MyCustomDialogFragment>();
}
public override void OnTerminate()
{
base.OnTerminate();
UnregisterActivityLifecycleCallbacks(this);
}
public void OnActivityCreated(Activity activity, Bundle savedInstanceState)
{
CrossCurrentActivity.Current.Activity = activity;
}
public void OnActivityDestroyed(Activity activity)
{
}
public void OnActivityPaused(Activity activity)
{
}
public void OnActivityResumed(Activity activity)
{
CrossCurrentActivity.Current.Activity = activity;
}
public void OnActivitySaveInstanceState(Activity activity, Bundle outState)
{
}
public void OnActivityStarted(Activity activity)
{
CrossCurrentActivity.Current.Activity = activity;
}
public void OnActivityStopped(Activity activity)
{
}
}
这是 MyCustomDialogFragment
的代码 public class MyCustomDialogFragment : FingerprintDialogFragment
{
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your fragment here
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var view = base.OnCreateView(inflater, container, savedInstanceState);
view.Background = new ColorDrawable(Color.Blue);
return view;
}
}
这是我的演示代码。