Reputation: 14638
Part of my app is to lock screen using a certain pattern the user chooses and unlocks it with the same pattern. I wish to use the same android default Pattern lock screen. I want the user to be able to set up multiple patterns and unlock the screen with these patterns.
Any ways I can do that? Is there some intent or class I can call to do that? Or do I have to develop such mechanisim from scratch? I have no idea where to start with
Heeeelp! Thank you
Upvotes: 0
Views: 6835
Reputation: 2132
You can call lockNow method by DevicePolicyManager
.
public class MobileDeviceAdminReceiver extends DeviceAdminReceiver {
}
ComponentName deviceAdminReceiver = new ComponentName(this, MobileDeviceAdminReceiver.class); // Register BroadcastReceiver in manifest;
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);// admin permission intent
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,deviceAdminReceiver);
Or create your custom lock screen that monitoring top activity and block it.
Upvotes: 0
Reputation: 1971
Lets try below code really helpful
Intent settingIntent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
startActivityForResult(settingIntent, 0);
many thanks
Upvotes: 2