screen-lock

Start Activity screen even if screen is locked in Android

痞子三分冷 提交于 2019-11-26 18:12:37
问题 How to start an Activity on device even if screen is locked. I tried as below but it's not working. Broadcast receiver: Intent alarmIntent = new Intent("android.intent.action.MAIN"); alarmIntent.setClass(context, Alarm.class); alarmIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); alarmIntent.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED + WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD + WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON + WindowManager.LayoutParams.FLAG_TURN_SCREEN

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

六月ゝ 毕业季﹏ 提交于 2019-11-26 08:19:33
问题 Is there any one that can help me with a code to set a password to lock the screen ? thx 回答1: 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);