android 指纹 分发,指纹身份验证 - Xamarin | Microsoft Docs

指纹身份验证Fingerprint Authentication

02/16/2018

本文内容

本指南讨论如何将 Android 6.0 中引入的指纹身份验证添加到 Xamarin.Android 应用程序。This guide discusses how to add fingerprint authentication, introduced in Android 6.0, to a Xamarin.Android application.

指纹身份验证概述Fingerprint Authentication Overview

在 Android 设备上引入指纹扫描仪为应用程序提供了传统的用户名/密码用户身份验证的替代方法。The arrival of fingerprint scanners on Android devices provides applications with an alternative to the traditional username/password method of user authentication. 相较于用户名和密码,采用指纹对用户进行身份验证使应用程序安全性的实现更具隐私性。The use of fingerprints to authenticate a user makes it possible for an application to incorporate security that is less intrusive than a username and password.

FingerprintManager API 适用于带指纹扫描仪的设备,FingerprintManager API 运行的是 API 级别 23 (Android 6.0) 或更高版本。The FingerprintManager APIs target devices with a fingerprint scanner and are running API level 23 (Android 6.0) or higher. API 位于 Android.Hardware.Fingerprints 命名空间中。The APIs are found in the Android.Hardware.Fingerprints namespace. Android Support Library v4 提供适用于旧版 Android 的指纹 API 版本。The Android Support Library v4 provides versions of the fingerprint APIs meant for older versions of Android. 兼容性 API 位于 Android.Support.v4.Hardware.Fingerprint 名称空间,通过 Xamarin.Android.Support.v4 NuGet 软件包进行分发。The compatibility APIs are found in the Android.Support.v4.Hardware.Fingerprint namespace, are distributed through the Xamarin.Android.Support.v4 NuGet package.

The FingerprintManager (and its Support Library counterpart, FingerprintManagerCompat) is the primary class for using the fingerprint scanning hardware. 此类是针对系统级服务(管理与硬件本身的交互)的 Android SDK 包装器。This class is an Android SDK wrapper around the system level service that manages interactions with the hardware itself. 它负责启动指纹扫描仪并响应扫描程序的反馈。It is responsible for starting the fingerprint scanner and for responding to feedback from the scanner. 此类的接口较简单,只包含三个成员:This class has a fairly straightforward interface with only three members:

Authenticate – 此方法将初始化硬件扫描仪并在后台启动服务,等待用户扫描其指纹。Authenticate – This method will initialize the hardware scanner and start the service in the background, waiting for the user to scan their fingerprint.

EnrolledFingerprints – 如果用户在设备中注册了一个或多个指纹,此属性将返回 true。EnrolledFingerprints – This property will return true if the user has registered one or more fingerprints with the device.

HardwareDetected – 此属性用于确定设备是否支持指纹扫描。HardwareDetected – This property is used to determine if the device supports fingerprint scanning.

Android 应用程序使用 FingerprintManager.Authenticate 方法启动指纹扫描仪。The FingerprintManager.Authenticate method is used by an Android application to start the fingerprint scanner. 以下代码片段举例说明如何使用 Support Library 兼容性 API 调用它:The following snippet is an example of how to invoke it using the Support Library compatibility APIs:

// context is any Android.Content.Context instance, typically the Activity

FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat.From(context);

fingerprintManager.Authenticate(FingerprintManager.CryptoObject crypto,

int flags,

CancellationSignal cancel,

FingerprintManagerCompat.AuthenticationCallback callback,

Handler handler

);

本指南将讨论如何使用 FingerprintManager API 为 Android 应用程序增加指纹身份验证功能。This guide will discuss how to use the FingerprintManager APIs to enhance an Android application with fingerprint authentication. 它将介绍如何实例化和创建 CryptoObject 以帮助保护指纹扫描仪的结果。It will cover how to instantiate and create a CryptoObject to help secure the results from the fingerprint scanner. 我们将讨论应用程序应如何子类化 FingerprintManager.AuthenticationCallback 并响应指纹扫描仪的反馈。We'll examine how an application should subclass FingerprintManager.AuthenticationCallback and respond to feedback from the fingerprint scanner. 最后,我们将了解如何在 Android 设备或模拟器上注册指纹,以及如何使用 adb 模拟指纹扫描。Finally, we'll see how to enroll a fingerprint on an Android device or emulator and how to use adb to simulate a fingerprint scan.

要求Requirements

指纹身份验证需要 Android 6.0(API 级别 23)或更高版本,以及带有指纹扫描器的设备。Fingerprint Authentication requires Android 6.0 (API level 23) or higher and a device with a fingerprint scanner.

已在设备上注册了指纹的用户才能进行身份验证。A fingerprint must already be enrolled with the device for each user that is to be authenticated. 这涉及设置使用密码、PIN、轻扫模式或面部识别的屏幕锁。This involves setting up a screen lock that uses a password, PIN, swipe pattern, or facial recognition. 可以在 Android 仿真器中模拟某些指纹身份验证功能。It is possible to simulate some of the fingerprint authentication functionality in an Android Emulator. 有关这两个主题的更多信息,请参阅注册指纹部分。For more information on these two topics, please see the Enrolling a Fingerprint section.

相关链接Related Links

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值