[英]Creating custom screen and keypad unlock android
我正在嘗試創建一個帶有解鎖選項的自定義android屏幕(基本上是覆蓋默認解鎖屏幕並覆蓋幻燈片解鎖按鈕的東西)。 解鎖后,它應直接進入鍵盤以輸入密碼並以默認方式運行。 我嘗試使用小部件創建此文件,但無法找到添加此內容的方法,例如解鎖屏幕。 任何幫助將不勝感激。我正在使用android studio。
這是您正在尋找的好例子。 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.
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.