Reputation: 1429
I'm developing a security enhancement android application. There is a need to lock the android phone, hence using Device admin and it works fine.
But, when setting a password, i'm in need of using Intents or i'm navigated to in-built UI screens to enter password.
Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
startActivity(intent);
Is there any way to set password without using default screens / without UI ?
Kindly help me..
Upvotes: 2
Views: 1043
Reputation: 46
DevicePolicyManager DPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
String pw = "abcd123";
DPM.resetPassword(pw, DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
Not sure this is what you need but it's how I set passwords for the user.
Upvotes: 3
Reputation: 11782
No - and the reason for this is that from Google's perspective (your requirements may vary, but you're in the minority) the user should always have a chance to know the password for their device. Allowing an application, even as a Device Policy Manager, to change the password without user input could lock a user out of the device they might need to function without them understanding why, which is a very poor UX design. You can reset the user's password, or, as you've already noted, launch the screens to help them change their password but that's the best you're going to be able to manage without a custom build of the OS.
Upvotes: 1