【问题标题】:Creating custom screen and keypad unlock android创建自定义屏幕和键盘解锁android
【发布时间】:2015-11-03 08:16:44
【问题描述】:

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

【问题讨论】:

  • 已经有很多关于这个的问题了......看看link1link2link3,......

标签: android button android-studio lockscreen android-keypad


【解决方案1】:

这是您正在寻找的一个很好的例子。 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.
        }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-23
    • 1970-01-01
    • 2016-12-10
    • 2013-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多