我想以编程方式设置锁屏密码,然后在执行循环时删除.我已经成功添加了设备管理,有人可以帮助我从我的应用程序本身设置和取消锁定屏幕密码.以下是我的设备管理工作代码
public class DevicePolicyDemoActivity extends Activity { static final String TAG = "DevicePolicyDemoActivity"; static final int ACTIVATION_REQUEST = 47; // IDentifIEs our request ID DevicePolicyManager devicePolicyManager; Componentname demoDeviceadmin; /** Called when the activity is first created. */ @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.main); // Initialize Device Policy Manager service and our receiver class devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POliCY_SERVICE); demoDeviceadmin = new Componentname(this, DemoDeviceadminReceiver.class); Intent intent = new Intent( DevicePolicyManager.ACTION_ADD_DEVICE_admin); intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_admin, demoDeviceadmin); intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "Your boss told you to do this"); startActivityForResult(intent, ACTIVATION_REQUEST); }}
解决方法:
对于设置密码,您可以使用以下代码:
devicePolicyManager.setPasswordQuality( demoDeviceadmin ,DevicePolicyManager.PASSWORD_QUAliTY_UnspecIFIED);devicePolicyManager.setPasswordMinimumLength( demoDeviceadmin, 5);boolean result = devicePolicyManager.resetPassword("123456", DevicePolicyManager.reset_PASSWORD_REQUIRE_ENTRY);
总结 以上是内存溢出为你收集整理的如何以编程方式在Android中设置和取消锁定屏幕密码全部内容,希望文章能够帮你解决如何以编程方式在Android中设置和取消锁定屏幕密码所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)