创建自定义屏幕和键盘解锁android



我正在尝试创建一个带有解锁选项的自定义android屏幕(基本上是覆盖默认解锁屏幕和滑动解锁按钮的东西)。解锁时,它应该直接指向键盘输入通行码,并以默认方式进行操作。我试着用小部件创建这个,但找不到像解锁屏幕一样添加这个的方法。如有任何帮助,我们将不胜感激。我正在使用安卓工作室。

这里有一个很好的例子说明您正在寻找什么。https://github.com/googlesamples/android-ConfirmCredential

private void showAuthenticationScreen() {
    // Create the Confirm Credentials screen. You can customize the title and description. Or
    // we will provide a generic one for you if you leave it null
    Intent intent = mKeyguardManager.createConfirmDeviceCredentialIntent(null, null);
    if (intent != null) {
        startActivityForResult(intent, REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS);
    }
}

这是用于打开结果和获取身份验证意图的小代码。但我建议你试着下载代码,看看它

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS) {
        // Challenge completed, proceed with using cipher
        if (resultCode == RESULT_OK) {
            if (tryEncrypt()) {
                showPurchaseConfirmation();
            }
        } else {
            // The user canceled or didn’t complete the lock screen
            // operation. Go to error/cancellation flow.
        }
    }
}

最新更新