發表文章

目前顯示的是有「screen lock」標籤的文章

Android Keyguard 呼叫螢幕解鎖驗證

圖片
android 的 Keyguard 可以用來呼叫螢幕解鎖來驗證,運用在有做自動登入時,避免使用者手機被偷,可以在app的重要功能再次要求解鎖 先檢查手機是否有開啟螢幕鎖定。 在Activity 叫起驗證頁,可以客制Title、Description private void showAuthenticationScreen() { if (keyguardManager.isKeyguardSecure()) { // Custom title description Intent intent = keyguardManager.createConfirmDeviceCredentialIntent("This is a custom title", "This is a custom description"); if (intent != null) { startActivityForResult(intent, REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS); }else{ this.result.setText("Secure lock screen hasn't set up"); } }else{ this.result.setText("Secure lock screen hasn't set up"); } } 接收解鎖結果: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS) { if (resultCode == RESULT_OK) { this.result.setText("Success"); } else {