Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9189537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:15:33+00:00 2026-06-17T20:15:33+00:00

In my application I disable the keyguard lock (i.e.Remove Lockscreen) using the code below

  • 0

In my application I disable the keyguard lock (i.e.Remove Lockscreen) using the code below and it works fine until I click on any notification in the notification bar. If I click on a notification the lock screen is automatically re-enabled. Any help is appreciated.

private void remove_lockscreen() {
    final CheckBoxPreference lock = (CheckBoxPreference) findPreference("remove_lockscreen");
    KeyguardManager km = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
    KeyguardLock kl = km.newKeyguardLock("keyguard_lock");
    if (lock.isChecked()) {
        prefEdit("remove_lockscreen", 1);
        Toast.makeText(getBaseContext(), "Lockscreen will not be shown", Toast.LENGTH_SHORT).show();
        kl.disableKeyguard();
    }
    else if (!lock.isChecked()) {
        prefEdit("remove_lockscreen", 0);
        Toast.makeText(getBaseContext(), "Lockscreen will be shown", Toast.LENGTH_SHORT).show();
        kl.reenableKeyguard();
        android.os.Process.killProcess(android.os.Process.myPid());
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:15:34+00:00Added an answer on June 17, 2026 at 8:15 pm

    I’ve noticed the same issue for some time. It only occurs on Honeycomb (Android 3.0) and up. After a great deal of experimentation and hair-pulling, I seem to have found a solution that works for me. It’s not clear exactly what’s going on or why, but here’s what I’ve figured out.

    It seems that on Android 3.0+, after the keyguard is disabled, when a notification is pressed, the old KeyguardLock expires, but thankfully the ACTION_USER_PRESENT Broadcast is fired at that point, so we have a chance to correct the issue.

    One point that’s not at all obvious from the documentation is that it seems to be necessary to reenable the old KeyguardLock before getting a new one and disabling it again. Another “gotcha” I discovered is that disabling through the new KeyguardLock immediately after reenabling through the old one produces only intermittent success. I resolved this by waiting 300ms before disabling.

    Here’s a slightly simplified version of my code; it should be easy to adapt to your app:

    private KeyguardLock kl;
    private KeyguardManager km;
    
    private final Handler mHandler = new Handler();
    
    private final Runnable runDisableKeyguard = new Runnable() {
        public void run() {
            kl = km.newKeyguardLock(getPackageName());
            kl.disableKeyguard();
        }
    };
    
    private void setEnablednessOfKeyguard(boolean enabled) {
        if (enabled) {
            if (kl != null) {
                unregisterReceiver(mUserPresentReceiver);
                mHandler.removeCallbacks(runDisableKeyguard);
                kl.reenableKeyguard();
                kl = null;
            }
        } else {
            if (km.inKeyguardRestrictedInputMode()) {
                registerReceiver(mUserPresentReceiver, userPresent);
            } else {
                if (kl != null)
                    kl.reenableKeyguard();
                else
                    registerReceiver(mUserPresentReceiver, userPresent);
    
                mHandler.postDelayed(runDisableKeyguard,  300);
            }
        }
    }
    
    private final BroadcastReceiver mUserPresentReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (Intent.ACTION_USER_PRESENT.equals(intent.getAction())){
                if (sp_store.getBoolean(KEY_DISABLE_LOCKING, false))
                    setEnablednessOfKeyguard(false);
            }
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to disable localization in an Android application? It must use
In my application I disable the Start menu using 'LowLevelKeyboardProc'. But i get the
Is there any way to disable my application from running on the background? I
I create ASP .NET MVC application. On button click I call JavaScript that disable
I am using DevExpress XtraGrid in c#.NET application. I want to disable or set
Is it possible using the iPhone SDK, to disable an application unless a pin
my application is MVC3 ASPX C#; I am trying to enable/disable Html.EditorFor using the
Is is possible to enable/disable firefox addons from an external application, preferably without using
Is there a way to disable Flash Audio while i'm using My Winform application
i create a lockscreen application and i need to disable a home button, so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.