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 7574069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:20:36+00:00 2026-05-30T16:20:36+00:00

Here’s the deal, I’ve been working on making a simple screen locker app that

  • 0

Here’s the deal, I’ve been working on making a simple screen locker app that mainly does the following:

  1. removes the keygaurd
  2. disables home and back buttons
  3. runs whenever the screen goes ON after going OFF
  4. runs at boot [not tested yet]

I’ve DONE MY HOMEWORK and used tons of links (especially on stackoverflow) and still so many problems

number 1 works perfectly 🙂

number 2 works but not as intended, when I press it, it open the dialog that asks the user for choosing a home application… I don’t want that! I want to make a lock screen app, not a home app. (code is provided at the end)

number 3 works before unlocking the screen, but after that, the application doesn’t know how to start itself automatically. I’ve implemented a Broadcast Receiver that is registered in code in the onCreat() method for the lock screen activity. I think this is the problem :S

number 4 this doesn’t work at all!

I was testing with a service, but still not working :'(


Code


Manifest I’m sure I’m using the the right permissions, am I?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="himura.test.mylockertest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="9" />

    <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" 
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

        <receiver 
            android:name=".EventsReciever"
            android:enabled="true" 
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.SCREEN_OFF"/>
                <action android:name="android.intent.action.SCREEN_ON"/>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>

        <service 
            android:enabled="true"
            android:name=".UpdateService"/>

        <activity
            android:name=".LockPage"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>

</manifest>

activity the layout is very simple, just one button to unlock 🙂

public class LockPage extends Activity {

    private Button ublockButton;

    @Override
    public void onAttachedToWindow() {
        //this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     
        this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);   
        super.onAttachedToWindow();    
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ///** FIRST THINGS FIRST, START THE SERVICE **/
        //startService(new Intent(this, myService.class));

        /** REGISTERING RECEIVER **/        
        IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(Intent.ACTION_BOOT_COMPLETED);
        BroadcastReceiver mReceiver = new EventsReciever();
        registerReceiver(mReceiver, filter);

        /** SETTING CONTENT VIEW**/
        setContentView(R.layout.lockscreen);

        /** REMOVING KEYGUARD RECEIVER **/
        KeyguardManager keyguardManager = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
        KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
        lock.disableKeyguard();

        /** NORMAL CODE **/
        ublockButton = (Button)findViewById(R.id.bUnlock);
        ublockButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void onBackPressed() {
        // Don't allow back to dismiss.
        return;
    }

    //only used in lockdown mode
    @Override
    protected void onPause() {
        super.onPause();
        Log.i("event","onPause");
        // Don't hang around.
        finish();
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.i("event","onStop");
        // Don't hang around.
        finish();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return false;
    }

}

Broadcast Receiver this handles 3 things, screen on/off and boot complete (or it should),,, I’ve been testing with Logs

public class EventsReciever extends BroadcastReceiver {
//works before unlocking
//after unlocking, keygaurd still off, but receiver has stopped

    public static boolean wasScreenOn = true;
    @Override
    public void onReceive(Context context, Intent recievedIntent) {

        Log.i("Check","[BroadCastReciever] onRecieve()");

        if (recievedIntent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
            wasScreenOn = false;
            Log.i("Check","[BroadCastReciever] Screen went OFF");
        } else if (recievedIntent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
            wasScreenOn = true;
            Log.i("Check","[BroadCastReciever] Screen went ON");

            Intent intent = new Intent(context, LockPage.class);
            context.startActivity(intent);
        }
        else if(recievedIntent.getAction().equals(Intent.ACTION_BOOT_COMPLETED))
        {
            Intent intent = new Intent(context, LockPage.class);
            context.startActivity(intent);
        //  Intent intent = new Intent(context, LockPage.class);
        //  context.startActivity(intent);
        //  Intent serviceLauncher = new Intent(context, UpdateService.class);
        //  context.startService(serviceLauncher);
        //  Log.v("TEST", "Service loaded at start");
        }
    }

}

Finally, the service doesn’t do anything now, I was trying to use it to start the lock screen after it gets unlocked for the first time

public class myService extends Service{

    @Override
    public void onCreate() {

        /** INITIALIZE RECEIVER **/
        //RegisterReciever();

    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
    // The standard pattern for implementing a Service is to create and run a new thread from onStartCommand 
    // to perform the processing in the background and stop the Service when it’s complete
        //RegisterReciever();

        return Service.START_STICKY;
    }

    /*private void RegisterReciever(){
        IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(Intent.ACTION_BOOT_COMPLETED);
        BroadcastReceiver mReceiver = new EventsReciever();
        registerReceiver(mReceiver, filter);
    }*/

}

more issues I’ve found on the internet includes the return of the status bar after turning the screen on (very bad)
in the native keyguard, there is the status bar, but it doesn’t function, is there a way to do that?

isn’t there a way to just make the locker activity, and tell the system that here u go, use this as the keyguard?

  • 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-05-30T16:20:37+00:00Added an answer on May 30, 2026 at 4:20 pm

    isn’t there a way to just make the locker activity, and tell the system that here u go, use this as the keyguard?

    If you create your own firmware, presumably there is a way to replace the keyguard with an alternative implementation, considering that most device manufacturers do it. You cannot replace the keyguard via the SDK.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the scenario: I'm writing an app that will watch for any changes
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is a simple timepicker to jQuery UI's datepicker <script type=text/javascript> /* <![CDATA[ */
Here's a query that works fine: SELECT rowid as msg_rowid, a, b, c FROM
Here is my code (Say we have a single button on the page that
Here's the flow that I am trying to achieve: 1) User uploads an audio

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.