"Lock Screen" with custom security password
Asked Answered
B

2

6

I have looked through lots of similar questions, and I have found out that it is not possible to make a Lock Screen as the standard android lockers. The thing that is possible is to make an app that disables the LockScreen and uses a different "lock" instead of the standard one. I am thinking about making a custom lockscreen with a different type of lock. What I do not know is possible is:

  1. Are there any ways of useing a .xml layout for a lockscreen
  2. Can I then write it like a normal app

I do not want referances to existing apps on the market.

Beefwood answered 3/3, 2012 at 18:33 Comment(0)
Z
1

I believe you are right because i did not find a way to replace the original lockscreen either. As you said, we can disable the original and fake another one.

I have a concept and you can find this page helpful too: http://chandan-tech.blogspot.com/2010/10/handling-screen-lock-unlock-in-android.html

You disable the original, add a listener to ACTION_SCREEN_ON, and once it is triggered, display your fake lockscreen, and from now you can write it like a normal app and i believe xml layout is totally practical.

To actually implement it , a service should also be made and has to run with system startup. In your activity you should also disable notification bar and buttons .

Zacharie answered 3/3, 2012 at 19:16 Comment(0)
P
0

You can try overriding KeyguardManager

KeyguardManager.KeyguardLock key;
KeyguardManager km=(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
//depreciated
key=km.newKeyguardLock("IN");

You must insert this in a service.Go as something like:

public class LockService extends Service{
BroadcastReceiver receiver;
@override
@SuppressWarnings("deprecation")
public void onCreate(){
KeyguardManager.KeyguardLock key;
KeyguardManager km=(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
//depreciated
key=km.newKeyguardLock("IN");
IntentFilter filter=new IntentFilter(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
receiver=new LockscreenReceiver();
registerReceiver(receiver,filter);
super.onCreate();
}

And then on LockscreenReceiver, you must implement this action:

public class LockscreenReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context,Intent intent){
String action=intent.getAction();
//if the screen was recently enabled, do this:
//If the screen was just turned on or it just booted up, start your Lock Activity
        if(action.equals(Intent.ACTION_SCREEN_OFF) || action.equals(Intent.ACTION_BOOT_COMPLETED))
        {
            Intent i = new Intent(context, MainActivity.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(i);
        }
}
}

afterwards, you must register or call service in MainActivity

startService(new Intent(this,LockscreenService.class));

To see this in action, go to https://github.com/thomasvidas/Simple-Lockscreen

Punctuation answered 3/11, 2015 at 16:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.