首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >创建自定义屏幕和键盘解锁android

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

Stack Overflow用户
提问于 2015-11-03 16:16:44
回答 1查看 794关注 0票数 0

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

EN

回答 1

Stack Overflow用户

发布于 2015-11-03 16:27:52

这里有一个很好的例子来说明你正在寻找的东西。https://github.com/googlesamples/android-ConfirmCredential

代码语言:javascript
复制
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);
    }
}

这是用于结果和获取身份验证的开放意图的小代码。但我建议尝试下载代码并查看它。

代码语言:javascript
复制
@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.
        }
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33494270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档