首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android : DeviceManager.setMaximumTimeToLock()不工作

Android : DeviceManager.setMaximumTimeToLock()不工作
EN

Stack Overflow用户
提问于 2015-04-08 19:26:36
回答 1查看 603关注 0票数 1
代码语言:javascript
复制
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文件,用于接收器。

代码语言:javascript
复制
 <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>

下面是我在活动结果中注册尝试秒数代码

代码语言:javascript
复制
    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);上没有设置锁定设备的时间。

EN

回答 1

Stack Overflow用户

发布于 2015-04-08 20:48:45

试试这个(来自javadoc):

调用设备管理员必须已请求USES_POLICY_FORCE_LOCK才能调用此方法;如果未请求,则将抛出安全异常。

检查at developer.android.com

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29513311

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档