Creating an Android Lock Screen App.
Asked Answered
P

1

31

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

Polysyllabic answered 6/1, 2014 at 5:15 Comment(6)
Well I figured there would be some kind of hint how hard this is, I mean for example theres an unruly amount on the market place, making me believe there are quite a certain number of developers who can, which you would go on to believe their would be some sort of tutorial!Polysyllabic
Check this link... forum.xda-developers.com/showthread.php?t=1754753Brush
A screen that could really disable switching out would be a horrible security flaw.Puto
Yes I have already done this kind of project, it's very much possible. There needs manifest permission as well as bootupreceiver and few more things. If you would like code, then inform me.Amateur
You may check my answer, I think will help you achieve what you want https://mcmap.net/q/83490/-creating-custom-lockscreen-in-android-closedRaneeraney
@SatyakiMukherjee can you share your source code?Plow
W
37

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

Witty answered 6/1, 2014 at 6:16 Comment(6)
The home key solution is partly working. It will override the home button only if the user will agree to define your app as the callback app for this action.Hurter
Yes sir, every action we do within the android app only after the approval of the user! i don't think it is a big deal?Witty
Well, you don't need the user's approval in order to override the 'back' button. The user will think that my app can control the 'home' button on its own and won't expect it to ask me to choose which app should control the home button..Hurter
Just use the Adenda SDK. It essentially extends the standard Android libraries to make things simpler on youTaritariff
@CigogneEveillee adendamedia.com/#intro do they provide sdk or app i have found their app which is paid how u use it ? can u pls explainLogicize
@Witty Is this possible for the latest API 28 & 29?Grosgrain

© 2022 - 2024 — McMap. All rights reserved.