當前位置: 首頁>>代碼示例>>Java>>正文


Java FingerprintManager類代碼示例

本文整理匯總了Java中android.hardware.fingerprint.FingerprintManager的典型用法代碼示例。如果您正苦於以下問題:Java FingerprintManager類的具體用法?Java FingerprintManager怎麽用?Java FingerprintManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FingerprintManager類屬於android.hardware.fingerprint包,在下文中一共展示了FingerprintManager類的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;
    }
}
 
開發者ID:kevalpatel2106,項目名稱:PasscodeView,代碼行數:25,代碼來源:FingerPrintAuthHelper.java

示例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;
}
 
開發者ID:OmarAflak,項目名稱:Fingerprint,代碼行數:8,代碼來源:Fingerprint.java

示例3: startFingerprintAuth

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.M)
private void startFingerprintAuth() throws GeneralSecurityException, IOException {
    Signature signature = Signature.getInstance("SHA256withECDSA");
    PrivateKey privateKey = fidoKeystore.getKeyPair(Preferences.getSettingsParam("username")).getPrivate();
    signature.initSign(privateKey);

    FingerprintAuthenticationDialogFragment fragment
            = new FingerprintAuthenticationDialogFragment();
    FingerprintManager.CryptoObject cryptoObj = new FingerprintManager.CryptoObject(signature);
    fragment.setCryptoObject(cryptoObj);
    fragment.setStage(
            FingerprintAuthenticationDialogFragment.Stage.FINGERPRINT);

    Log.d(TAG, "Showing fragment: " + fragment);
    fragment.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
}
 
開發者ID:eBay,項目名稱:UAF,代碼行數:17,代碼來源:ExampleFidoUafActivity.java

示例4: isHardwarePresent

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@Override
public boolean isHardwarePresent() {
    final FingerprintManager fingerprintManager = fingerprintManager();
    if (fingerprintManager == null) return false;
    // Normally, a security exception is only thrown if you don't have the USE_FINGERPRINT
    // permission in your manifest. However, some OEMs have pushed updates to M for phones
    // that don't have sensors at all, and for some reason decided not to implement the
    // USE_FINGERPRINT permission. So on those devices, a SecurityException is raised no matter
    // what. This has been confirmed on a number of devices, including the LG LS770, LS991,
    // and the HTC One M8.
    //
    // On Robolectric, FingerprintManager.isHardwareDetected raises an NPE.
    try {
        return fingerprintManager.isHardwareDetected();
    } catch (SecurityException | NullPointerException e) {
        logger.logException(e, "MarshmallowReprintModule: isHardwareDetected failed unexpectedly");
        return false;
    }
}
 
開發者ID:ajalt,項目名稱:reprint,代碼行數:20,代碼來源:MarshmallowReprintModule.java

示例5: onAuthenticationSucceeded

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
/**
 * Called by {@link FingerprintManager} if the authentication succeeded.
 */
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
    mErrorTextView.removeCallbacks(mResetErrorTextRunnable);
    mIcon.setImageResource(R.drawable.ic_fingerprint_success);
    mErrorTextView.setTextColor(
            mErrorTextView.getResources().getColor(R.color.success_color, null));
    mErrorTextView.setText(
            mErrorTextView.getResources().getString(R.string.pin_code_fingerprint_success));
    mIcon.postDelayed(new Runnable() {
        @Override
        public void run() {
            mCallback.onAuthenticated();
        }
    }, SUCCESS_DELAY_MILLIS);
}
 
開發者ID:sfilmak,項目名稱:MakiLite,代碼行數:19,代碼來源:FingerprintUiHelper.java

示例6: startAuth

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
public void startAuth(FingerprintManager manager,
                      FingerprintManager.CryptoObject cryptoObject) {

    cancellationSignal = new CancellationSignal();

    if (ActivityCompat.checkSelfPermission(context,
            Manifest.permission.USE_FINGERPRINT) !=
            PackageManager.PERMISSION_GRANTED) {
        return;
    }
    manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}
 
開發者ID:noosomii,項目名稱:FingerprintDemo,代碼行數:13,代碼來源:FingerprintHelper.java

示例7: checkSensorState

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
public static SensorState checkSensorState(Context context) {
    if (checkFingerprintCompatibility(context)) {
        KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);

        if (!keyguardManager.isKeyguardSecure()) {
            return SensorState.NOT_BLOCKED;
        }

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || !((FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE)).hasEnrolledFingerprints()) {
            return SensorState.NO_FINGERPRINTS;
        }

        return SensorState.READY;
    } else {
        return SensorState.NOT_SUPPORTED;
    }
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:18,代碼來源:FingerprintTools.java

示例8: onAuthenticationSucceeded

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@Override
public void onAuthenticationSucceeded(
        FingerprintManager.AuthenticationResult result) {

    String pwd = WCFPXSharedPreferencesUtil.getPwd(mContext);
    //TODO 這裏邏輯有待修改
    if (pwd != null && pwd.length() > 0) {
        if (mEditText != null) {
            mEditText.setText(pwd);
        }
        else {
            showToast("Error: mEditText null");
        }
    } else {
        showToast("Sorry, but you have not set the password in WeChatFingerprintPay yet");
    }
}
 
開發者ID:aboutZZ,項目名稱:WeChatFingerprintPay,代碼行數:18,代碼來源:FingerprintHandler.java

示例9: 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);
    }
}
 
開發者ID:aboutZZ,項目名稱:WeChatFingerprintPay,代碼行數:25,代碼來源:PayHook.java

示例10: onAuthenticationSucceeded

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
    fingerprintResult = result;
    mErrorTextView.removeCallbacks(mResetErrorTextRunnable);
    int ic_fingerprint_success_id = mContext.getResources()
            .getIdentifier("ic_fingerprint_success", "drawable", FingerprintAuth.packageName);
    mIcon.setImageResource(ic_fingerprint_success_id);
    int success_color_id = mContext.getResources()
            .getIdentifier("success_color", "color", FingerprintAuth.packageName);
    mErrorTextView.setTextColor(
            mErrorTextView.getResources().getColor(success_color_id, null));
    int fingerprint_success_id = mContext.getResources()
            .getIdentifier("fingerprint_success", "string", FingerprintAuth.packageName);
    mErrorTextView.setText(
            mErrorTextView.getResources().getString(fingerprint_success_id));
    mIcon.postDelayed(new Runnable() {
        @Override
        public void run() {
            mCallback.onAuthenticated(fingerprintResult);
        }
    }, SUCCESS_DELAY_MILLIS);
}
 
開發者ID:alex-shpak,項目名稱:keemob,代碼行數:23,代碼來源:FingerprintUiHelper.java

示例11: onAuthentication

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@Override
public void onAuthentication(int helpOrErrorCode, CharSequence infoString, FingerprintManager.AuthenticationResult authenticationResult, int authCode) {
    switch (authCode) {
        case ResponseCode.AUTH_ERROR:
            // Show appropriate message
            break;
        case ResponseCode.AUTH_FAILED:
            // Show appropriate message
            showToast("Authentication Failed");
            break;
        case ResponseCode.AUTH_HELP:
            // Show appropriate message
            break;
        case ResponseCode.AUTH_SUCCESS:
            // Do whatever you want
            showToast("Authentication Success");
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                fingerprintResultsHandler.restartListening(fingerPrintHelper.getFingerprintManager(), fingerPrintHelper.getCryptoObject());
            }
            break;
    }
}
 
開發者ID:dev-prajwal21,項目名稱:FingerprintAssistant,代碼行數:23,代碼來源:MainActivity.java

示例12: isSensorAvailable

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@ReactMethod
public void isSensorAvailable(final Promise promise) {
    
    response = Arguments.createMap();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (ActivityCompat.checkSelfPermission(mReactContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
            sendResponse("failed", "You haven't allow this app to use your fingerprint sensor", promise);
            return;
        }
        
        if (mReactContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) ||
            ((FingerprintManager) mReactContext.getSystemService(Context.FINGERPRINT_SERVICE)).isHardwareDetected()) {
            if (((FingerprintManager) mReactContext.getSystemService(Context.FINGERPRINT_SERVICE)).hasEnrolledFingerprints()) {
                sendResponse("ok", null, promise);
            } else {
                sendResponse("failed", "You have fingerprint sensor, but you should set it enabled in your settings to use with this app", promise);
            }
        } else {
            sendResponse("failed", "You don\'t have appropriate hardware", promise);
        }
    } else {
        sendResponse("failed", "You don\'t have appropriate hardware", promise);
    }
}
 
開發者ID:ElekenAgency,項目名稱:react-native-touch-id-android,代碼行數:25,代碼來源:FingerprintModule.java

示例13: setupFingerprintStuff

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.M)
public void setupFingerprintStuff() {
    fingerprintManager = (FingerprintManager) this.getSystemService(Context.FINGERPRINT_SERVICE);
    fingerprintHelper = new FingerprintHelper(this);
    try {
        generateKey();

        if (cipherInit()) {
            cryptoObject = new FingerprintManager.CryptoObject(cipher);
            fingerprintHelper.startAuth(fingerprintManager, cryptoObject);
        }

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
開發者ID:manuelsc,項目名稱:Lunary-Ethereum-Wallet,代碼行數:17,代碼來源:AppLockActivity.java

示例14: startAuth

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
public void startAuth(FingerprintManager manager,
                      FingerprintManager.CryptoObject cryptoObject) {

    cancellationSignal = new CancellationSignal();

    if (ActivityCompat.checkSelfPermission(appContext,
            Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {

        Toast.makeText(appContext,
                appContext.getString(R.string.fingerprint_error_no_permission),
                Toast.LENGTH_LONG).show();

        return;
    }

    manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}
 
開發者ID:hacktoberfest17,項目名稱:programming,代碼行數:18,代碼來源:FingerprintHandler.java

示例15: inicializarSeguranca

import android.hardware.fingerprint.FingerprintManager; //導入依賴的package包/類
private void inicializarSeguranca() {

        if (ActivityCompat.checkSelfPermission(this,
                Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {

            Toast.makeText(this,
                    getString(R.string.fingerprint_error_no_permission),
                    Toast.LENGTH_LONG).show();

            return;
        }

        keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
        fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);

        keystoreManager = new AndroidKeystoreManager(KEY_NAME);
        keystoreManager.generateKey();

        if (keystoreManager.cipherInit()) {
            cryptoObject = new FingerprintManager.CryptoObject(keystoreManager.getCipher());
        }
    }
 
開發者ID:hacktoberfest17,項目名稱:programming,代碼行數:23,代碼來源:MainActivity.java


注:本文中的android.hardware.fingerprint.FingerprintManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。