Creating an Android Lock Screen App.

Yes, it is possible. This is a simple lock screen Source Code from GitHub

Creating an app that works like a lock is no big deal but as you said for Home key issue, I would suggest you go on and develop the App as much as you need and the only final area you would get stuck is the home key control so, try to find some tricky way to get the control of home key and make it as an app launcher for your lock app. It is not very complicated but kinda tricky though. I will post you, if I can find any Home-key access source codes

PS:

Here is the tutorial for accessing Home Key

I found the home key override somewhere. Add these lines in the App Manifest.

Following two lines will do the magic

 <action android:name="android.intent.action.MAIN" />              
        <category android:name="android.intent.category.HOME" />                 
        <category android:name="android.intent.category.DEFAULT" />               

and override this method in your activity

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

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if(keyCode == KeyEvent.KEYCODE_HOME)
    {
        Log.i("Home Button","Clicked");
    }
    if(keyCode==KeyEvent.KEYCODE_BACK)
    {
        finish();
    }
    return false;
}

Keep in mind that I didn’t test these codes or methods, just tried to help you (you might find some drawbacks).

PS: based on the votes I can guarantee that my suggestion is working and you can develop such app with the above help 🙂

Leave a Comment