Start Activity screen even if screen is locked in Android

You can achieve this in two ways: using wake lock as explained by @Yup in this post. using window flags. Using window flags: Open the Activity A which you want to start in onReceive(…). Paste this in onCreate() of that Activity A final Window win= getWindow(); win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); Make sure you’re … Read more

How can i set up screen lock with a password programmatically?

Use this code in your App, it works for me: DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); ComponentName demoDeviceAdmin = new ComponentName(this, name of activity); devicePolicyManager.setPasswordQuality( demoDeviceAdmin,DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED); devicePolicyManager.setPasswordMinimumLength(demoDeviceAdmin, 5); boolean result = devicePolicyManager.resetPassword(“123456”, DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY); Toast.makeText(this, “button_lock_password_device…”+result, Toast.LENGTH_LONG).show();