使用createConfirmDeviceCredentialIntent()时在backpress中获取错误

时间:2018-05-04 10:32:21

标签: java android authentication onbackpressed android-fingerprint-api

我在我的Android应用程序中使用createConfirmDeviceCredentialIntent()进行引脚验证。如果我从我的pin身份验证意图中按回按钮,createConfirmDeviceCredentialIntent将关闭并显示主要活动。我想从那个意图,如果有人按下按钮,应用程序应该关闭。 `KeyguardManager keyguardManager =(KeyguardManager)getSystemService(KEYGUARD_SERVICE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Intent i = keyguardManager.createConfirmDeviceCredentialIntent("unlock", "confirm_pattern");
        try {
            startActivityForResult(i, LOCK_REQUEST_CODE);
        } catch (Exception e) {
            Log.d("exception occured", e.toString());
        }
    }    @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case LOCK_REQUEST_CODE:
            if (resultCode == RESULT_OK) {
                Intent a = new Intent(MainActivity.this, HomeActivity.class);
                startActivity(a);

                textView.setText("unlock_success");
            } else {

                textView.setText("unlock_failed");
            }

            break;
    }
}`

0 个答案:

没有答案