本文整理匯總了Java中android.hardware.fingerprint.FingerprintManager.hasEnrolledFingerprints方法的典型用法代碼示例。如果您正苦於以下問題:Java FingerprintManager.hasEnrolledFingerprints方法的具體用法?Java FingerprintManager.hasEnrolledFingerprints怎麽用?Java FingerprintManager.hasEnrolledFingerprints使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.fingerprint.FingerprintManager
的用法示例。
在下文中一共展示了FingerprintManager.hasEnrolledFingerprints方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkFingerPrintAvailability
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
/**
* Check if the finger print hardware is available.
*
* @param context instance of the caller.
* @return true if finger print authentication is supported.
*/
@SuppressWarnings("MissingPermission")
private boolean checkFingerPrintAvailability(@NonNull Context context) {
// Check if we're running on Android 6.0 (M) or higher
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()) {
return false;
} else if (!fingerprintManager.hasEnrolledFingerprints()) {
return false;
}
return true;
} else {
return false;
}
}
示例2: isAvailable
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
public static boolean isAvailable(Context context){
FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
if(fingerprintManager!=null){
return (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints());
}
return false;
}
示例3: initFingerPrint
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
private void initFingerPrint(Context context) {
KeyguardManager keyguardManager =
(KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
FingerprintManager fingerprintManager =
(FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
if (!fingerprintManager.isHardwareDetected()) {
Toast.makeText(context, "Your device doesn't support fingerprint authentication", Toast.LENGTH_LONG).show();
} else if (context.checkSelfPermission(Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(context, "Please enable the fingerprint permission", Toast.LENGTH_LONG).show();
} else if (!fingerprintManager.hasEnrolledFingerprints()) {
Toast.makeText(
context,
"No fingerprint configured. Please register at least one fingerprint in your device's Settings",
Toast.LENGTH_LONG).show();
} else if (!keyguardManager.isKeyguardSecure()) {
Toast.makeText(
context,
"Please enable lock screen security in your device's Settings",
Toast.LENGTH_LONG).show();
} else {
fHandler = new FingerprintHandler(context);
}
}
示例4: isFingerPrintEnrolled
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
/**
* Check if the device has any fingerprint registered?
* <p>
* If no fingerprint registered, use {@link #openSecuritySettings(Context)} to open security settings.
*
* @param context instance
* @return true if any fingerprint is register.
*/
@SuppressWarnings({"MissingPermission", "WeakerAccess"})
public static boolean isFingerPrintEnrolled(Context context) {
// Check if we're running on Android 6.0 (M) or higher
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);
return !(!fingerprintManager.isHardwareDetected() || !fingerprintManager.hasEnrolledFingerprints());
} else {
return false;
}
}
示例5: hasDeviceFingerprintSupport
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
public static boolean hasDeviceFingerprintSupport(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
return false;
}
return fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints();
} else {
return false;
}
}
示例6: isFingerAvailable
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
/**
* 判斷指紋是否可用, 1:有指紋模塊, 2:錄入了指紋
*/
public static boolean isFingerAvailable(Context context) {
if (Build.VERSION.SDK_INT < 23) {
return false;
}
FingerprintManager manager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
KeyguardManager mKeyManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
//權限檢查
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT)
!= PackageManager.PERMISSION_GRANTED) {
return false;
}
//判斷硬件是否支持指紋識別
if (!manager.isHardwareDetected()) {
return false;
}
//判斷 是否開啟鎖屏密碼
if (!mKeyManager.isKeyguardSecure()) {
return false;
}
//判斷是否有指紋錄入
if (!manager.hasEnrolledFingerprints()) {
return false;
}
return true;
}
示例7: isFingerprintReady
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.M)
public static boolean isFingerprintReady(Context context) {
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 (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
if (!fingerprintManager.isHardwareDetected()) {
return false;
} else if (!fingerprintManager.hasEnrolledFingerprints()) {
return false;
} else {
return true;
}
} else {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, Manifest.permission.USE_FINGERPRINT)) {
System.out.println("asd");
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.USE_FINGERPRINT}, 0);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
}
return false;
}
示例8: supportsFingerprintAuth
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
private boolean supportsFingerprintAuth() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
// noinspection ResourceType
return fingerprintManager.isHardwareDetected()
&& fingerprintManager.hasEnrolledFingerprints();
}
return false;
}
示例9: hasFingerprintRegistered
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@Override
public boolean hasFingerprintRegistered() throws SecurityException {
final FingerprintManager fingerprintManager = fingerprintManager();
if (fingerprintManager == null) return false;
// Some devices with fingerprint sensors throw an IllegalStateException when trying to parse an
// internal settings file during this call. See #29.
try {
return fingerprintManager.hasEnrolledFingerprints();
} catch (IllegalStateException e) {
logger.logException(e, "MarshmallowReprintModule: hasEnrolledFingerprints failed unexpectedly");
return false;
}
}
示例10: onCreate
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_set_security);
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
mPatternView = (LockPatternView) ViewUtils.$$(this, R.id.pattern_view);
mCancel = ViewUtils.$$(this, R.id.cancel);
mSet = ViewUtils.$$(this, R.id.set);
mFingerprint = (CheckBox) ViewUtils.$$(this, R.id.fingerprint_checkbox);
String pattern = Settings.getSecurity();
if (!TextUtils.isEmpty(pattern)) {
mPatternView.setPattern(LockPatternView.DisplayMode.Correct,
LockPatternUtils.stringToPattern(pattern));
}
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
// The line below prevents the false positive inspection from Android Studio
// noinspection ResourceType
if (fingerprintManager.hasEnrolledFingerprints()) {
mFingerprint.setVisibility(View.VISIBLE);
mFingerprint.setChecked(Settings.getEnableFingerprint());
}
}
mCancel.setOnClickListener(this);
mSet.setOnClickListener(this);
}
示例11: onCreate
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mKeyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
mFingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
// Checking fingerprint permission.
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.USE_FINGERPRINT) !=
PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this,
"Fingerprint authentication permission not enabled",
Toast.LENGTH_LONG).show();
return;
}
// Checking Device support fingerprint or not.
if (mFingerprintManager.isHardwareDetected()) {
// Not setting lock screen with imprint.
if (!mKeyguardManager.isKeyguardSecure()) {
Toast.makeText(this,
"Lock screen security not enabled in Settings",
Toast.LENGTH_LONG).show();
return;
}
// Not registered at least one fingerprint in Settings.
if (!mFingerprintManager.hasEnrolledFingerprints()) {
Toast.makeText(this,
"Register at least one fingerprint in Settings",
Toast.LENGTH_LONG).show();
return;
}
generateKey();
if (initCipher()) {
mCryptoObject = new FingerprintManager.CryptoObject(cipher);
mFingerprintHelper = new FingerprintHelper(this);
}
}
}
示例12: isAvailable
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
public static boolean isAvailable(Context context){
FingerprintManager manager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
return (manager!=null && manager.isHardwareDetected() && manager.hasEnrolledFingerprints());
}
示例13: onCreate
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_login);
setTitle("Fingerprint Authentication");
auth_status = (SwirlView) findViewById(R.id.fp_stat);
auth_status.setState(SwirlView.State.ON,true);
// If you’ve set your app’s minSdkVersion to anything lower than 23, then you’ll need to verify that the device is running Marshmallow
// or higher before executing any fingerprint-related code
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//Get an instance of KeyguardManager and FingerprintManager//
keyguardManager =
(KeyguardManager) getSystemService(KEYGUARD_SERVICE);
fingerprintManager =
(FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
//Check whether the device has a fingerprint sensor//
if (!fingerprintManager.isHardwareDetected()) {
// If a fingerprint sensor isn’t available, then inform the user that they’ll be unable to use your app’s fingerprint functionality//
MDToast.makeText(this,"Your device doesn't support fingerprint authentication",MDToast.LENGTH_LONG,MDToast.TYPE_INFO).show();
}
//Check whether the user has granted your app the USE_FINGERPRINT permission//
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
// If your app doesn't have this permission, then display the following text//
MDToast.makeText(this,"Please enable the fingerprint permission",MDToast.LENGTH_LONG,MDToast.TYPE_INFO).show();
}
//Check that the user has registered at least one fingerprint//
if (!fingerprintManager.hasEnrolledFingerprints()) {
// If the user hasn’t configured any fingerprints, then display the following message//
MDToast.makeText(this,"No fingerprint configured. Please register at least one fingerprint in your device's Settings",MDToast.LENGTH_LONG,MDToast.TYPE_INFO).show();
}
//Check that the lockscreen is secured//
if (!keyguardManager.isKeyguardSecure()) {
// If the user hasn’t secured their lockscreen with a PIN password or pattern, then display the following text//
MDToast.makeText(this,"Please enable lockscreen security in your device's Settings",MDToast.LENGTH_LONG,MDToast.TYPE_INFO).show();
} else {
try {
generateKey();
} catch (FingerprintException e) {
e.printStackTrace();
}
if (initCipher()) {
//If the cipher is initialized successfully, then create a CryptoObject instance//
cryptoObject = new FingerprintManager.CryptoObject(cipher);
// Here, I’m referencing the FingerprintHandler class that we’ll create in the next section. This class will be responsible
// for starting the authentication process (via the startAuth method) and processing the authentication process events//
FingerprintHandler helper = new FingerprintHandler(this,this);
helper.startAuth(fingerprintManager, cryptoObject);
}
}
}
}
示例14: checkAndEnableFingerPrintService
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
/**
* @return Returns result code, an integer which can be any one of the following,<br/><br/>
* <b>FINGERPRINT_SENSOR_NOT_FOUND - 100<br/><br/></b>
* <b>PERMISSION_NOT_GRANTED_TO_ACCESS_FINGERPRINT_SENSOR - 200<br/><br/></b>
* <b>NO_FINGER_PRINTS_ENROLLED_IN_THE_DEVICE - 300<br/><br/></b>
* <b>OS_DOES_NOT_SUPPORT_FINGERPRINT_API - 400<br/><br/></b>
* <b>FAILED_INITIALISING_FINGERPRINT_SERVICE - 500<br/><br/></b>
* <b>FINGERPRINT_INITIALISATION_SUCCESS- 600<br/><br/></b>
* <b>KEY_GUARD_DISABLED - 700<br/><br/></b>
*/
public int checkAndEnableFingerPrintService() {
KeyguardManager keyguardManager = (KeyguardManager) mContext.getSystemService(KEYGUARD_SERVICE);
fingerprintManager = (FingerprintManager) mContext.getSystemService(FINGERPRINT_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!fingerprintManager.isHardwareDetected()) {
// Check if fingerprint sensor is available
return ResponseCode.FINGER_PRINT_SENSOR_UNAVAILABLE;
} else {
// Check if permission is granted to access fingerprint sensor
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
return ResponseCode.ENABLE_FINGER_PRINT_SENSOR_ACCESS;
} else {
// Check if device is keyguard protected
if (!keyguardManager.isKeyguardSecure()) {
return ResponseCode.DEVICE_NOT_KEY_GUARD_SECURED;
} else {
// Check if any fingerprints are enrolled
if (!fingerprintManager.hasEnrolledFingerprints()) {
return ResponseCode.NO_FINGER_PRINTS_ARE_ENROLLED;
} else {
if (generateKey()) {
if (cipherInit()) {
cryptoObject = new FingerprintManager.CryptoObject(cipher);
return ResponseCode.FINGERPRINT_SERVICE_INITIALISATION_SUCCESS;
} else {
return ResponseCode.FINGERPRINT_SERVICE_INITIALISATION_FAILED;
}
} else {
return ResponseCode.FINGERPRINT_SERVICE_INITIALISATION_FAILED;
}
}
}
}
}
} else {
return ResponseCode.OS_NOT_SUPPORTED;
}
}
示例15: hasEnrolledFingerprints
import android.hardware.fingerprint.FingerprintManager; //導入方法依賴的package包/類
public static boolean hasEnrolledFingerprints(Context context) {
final FingerprintManager fp = getFingerprintManagerOrNull(context);
return (fp != null) && fp.hasEnrolledFingerprints();
}