创建自定义屏幕和按键解锁android
问题描述:
我想创建一个自定义android屏幕解锁选项(基本上是覆盖默认解锁屏幕,并覆盖幻灯片解锁按钮)。在解锁时,它应指向键盘以输入密码,并以默认方式运行。 我试图创建这个小部件,但无法找到一种方法来添加这个像解锁屏幕。任何帮助将不胜感激。我正在使用android studio。创建自定义屏幕和按键解锁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.
}
}
}
关于这个问题已经有很多了...请看看[link1](http://*.com/questions/20943407/create-an-android-lock-screen),[link2 ](http://*.com/questions/10864300/create-a-lock-screen-of-my-own),[link3](http://*.com/questions/21983462/creating-custom-lockscreen -in-机器人),... – Marko