Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating an Android Lock Screen App.

How to create a lock-screen app that acts as a lock for android mobile. I did find one, But it was poorly constructed code wise and if I pressed the physical home key, it unlocked, making the application pointless.

I did come across a forum stating some method of blocking home button functionality was removed in Android 4.x

Yet, I have an awesome idea for a lock-screen but no ground to get started. If anyone has any knowledge on the subject, I'd love to hear it.

Thanks all :-)

like image 768
user3047494 Avatar asked Jan 06 '14 05:01

user3047494


People also ask

Can you customize Android lock screen?

Once you access the Wallpapers section, look for the Lock Screen customization option or select any image appearing in the wallpaper section. It will give you an option to apply the wallpaper on your Homepage or lock screen. Note: Some Android smartphones offer this option in their Gallery app as well.


1 Answers

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 :)

like image 184
Kirk Avatar answered Oct 01 '22 00:10

Kirk