I am making a device policy app in android in that we have several task to perform on of the task is:
We want the user to do attempts on screen lock,when 5 attempts been made to user there is 30 seconds timer popup in android system dialog. we want to increase and decrease that seconds to minutes and so on.
We have use
DevicepolicyManager.setMaximumTimeToLock(ourDeviceAdmin,50000L);
in the app. But its seems to be not working in emulator as well as real device
so what to do for that in action to run.下面是我的android-manifest文件,用于接收器。
<receiver
android:name="com.zealous.devicepolicy.DemoDeviceAdminReceiver"
android:permission="android.permission.BIND_DEVICE_ADMIN" >
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_admin_sample" />
</receiver>下面是我在活动结果中注册尝试秒数代码
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case ACTIVATION_REQUEST:
if (resultCode == Activity.RESULT_OK) {
Log.i("Camera_debug", "Administration enabled!");
btn.setChecked(true);
// 50000 equals 50 seconds
devicePolicyManager.setMaximumTimeToLock(devicepolicyAdmin, 50000L);
} else {
Log.i("Camera_Debug", "Administration enable FAILED!");
btn.setChecked(false);
}
}
super.onActivityResult(requestCode, resultCode, data);
}这是我的全部,但在devicePolicyManager.setMaximumTimeToLock(devicepolicyAdmin,50000L);上没有设置锁定设备的时间。
发布于 2015-04-08 20:48:45
试试这个(来自javadoc):
调用设备管理员必须已请求USES_POLICY_FORCE_LOCK才能调用此方法;如果未请求,则将抛出安全异常。
检查at developer.android.com
https://stackoverflow.com/questions/29513311
复制相似问题