How to make our own lock screen in android instead of default lock screen [duplicate]
Asked Answered
W

1

10

I have an idea of creating my own phone lock app similar to android pattern lock. I need to display or start my app whenever the phone boots/restarts/phone, lock/phone, and unlock. I don't know how to make the app appear instead of default lock screen and to hide the default lock screen. So my questions are:

  1. How to display or start my app instead of default lock screen
  2. What is

    getWindow().addFlags(
      WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | 
      WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | 
      WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | 
      WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    

How this is helpful?

  1. What is

    public class BootReciever extends BroadcastReceiver {
    
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction() != null) {
                if (intent.getAction().equals(Intent.ACTION_USER_PRESENT)) {
                Intent s = new  Intent(context,ViewPagerMainActivity.class);
                s.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(s);
                }
            }
        }
    }
    

How this is helpful?

  1. How do you show the home page after my app finishes its work?
Welkin answered 6/7, 2014 at 17:49 Comment(1)
You may check my answer, I think will help you achieve what you want https://mcmap.net/q/83490/-creating-custom-lockscreen-in-android-closedShoestring
O
22

Codes that you have used in point 2 should be used as answer of your question 1. Reference is Android activity over default lock screen.

For question 2, see these relevant links:

Before answering your question 3,i would like to ask you, do you have knowledge about BroadcastReceiver? In short it is-

A broadcast receiver (short receiver) is an Android component which allows you to register for system or application events. All registered receivers for an event are notified by the Android runtime once this event happens.

For example, applications can register for the ACTION_BOOT_COMPLETED system event which is fired once the Android system has completed the boot process.

Now come to your question 4, you can show home page programmatically by this code:

Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);

Refer: Going to home screen programmatically

And last of all i would like to provide you some links that may help you to make a custom lock screen:

Onia answered 6/7, 2014 at 18:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.