javaandroidkeyguard

Keyguard manager how to remove cancel button


When using KeyguardManager, how do I remove the cancel button? There is a cancel button that appears on left side.

if(km.isKeyguardSecure()) {
            Intent i = km.createConfirmDeviceCredentialIntent("Authentication required", "password");
            startActivityForResult(i, CODE_AUTHENTICATION_VERIFICATION);
        }

  @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode==RESULT_OK && requestCode==CODE_AUTHENTICATION_VERIFICATION)
        {
            Toast.makeText(this, "Success: Verified user's identity", Toast.LENGTH_SHORT).show();
            Session.setLock(false);
            startActivity(new Intent(this,WelcomeACtivity.class));
        }
}

Solution

  • @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
            if(resultCode==RESULT_OK && requestCode==CODE_AUTHENTICATION_VERIFICATION)
            {
                Toast.makeText(this, "Success: Verified user's identity", Toast.LENGTH_SHORT).show();
                Session.setLock(false);
    
                startActivity(new Intent(context,WelcomeACtivity.class));
    
            }
            else if(resultCode == RESULT_CANCELED && requestCode == CODE_AUTHENTICATION_VERIFICATION)
            {
                finish();
            }
            else
            {
                Toast.makeText(this, "Failure: Unable to verify user's identity", Toast.LENGTH_SHORT).show();
    
            }
        }