我正在尝试创建一个带有解锁选项的自定义android屏幕(基本上是覆盖默认解锁屏幕和幻灯片解锁按钮的东西)。在解锁时,它应该指向键盘以输入通行码,并以默认方式运行。我试着用widget创建它,但找不到像解锁屏幕一样添加它的方法。如有任何帮助,我将不胜感激。我正在使用android studio。
发布于 2015-11-03 16:27:52
这里有一个很好的例子来说明你正在寻找的东西。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.
}
}
}https://stackoverflow.com/questions/33494270
复制相似问题