Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android设备管理员在为应用程序激活时未打开_Android - Fatal编程技术网

android设备管理员在为应用程序激活时未打开

android设备管理员在为应用程序激活时未打开,android,Android,我正在通过激发意图从我的应用程序激活移动设备管理员 我的应用程序在第一次试用时打开设备管理页面。现在我从我的应用程序激活设备管理员 但当它重新打开(去激活或停用)时,它不会打开设备管理页面,甚至我的代码也会运行触发设备管理的那一行 打开设备管理页的代码: ComponentName mDeviceAdminSample = new ComponentName(mContext, MGDeviceAdminReciever.class); Intent intent = new

我正在通过激发意图从我的应用程序激活移动设备管理员

我的应用程序在第一次试用时打开设备管理页面。现在我从我的应用程序激活设备管理员

但当它重新打开(去激活或停用)时,它不会打开设备管理页面,甚至我的代码也会运行触发设备管理的那一行

打开设备管理页的代码:

     ComponentName mDeviceAdminSample = new ComponentName(mContext, MGDeviceAdminReciever.class);
     Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
     intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,mDeviceAdminSample);
     intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,mContext.getString(R.string.enable_device_manager_declare));
     mContext.startActivity(intent);

这是它的,但它不会打开设备管理页面,而是在内部禁用它

            DevicePolicyManager mDPM = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
            ComponentName mDeviceAdminSample = new ComponentName(mContext, MGDeviceAdminReciever.class);
            if (isChecked) {
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO) {

                    if (!PreferenceDataHelper.getUIEnable(mContext, PreferenceDataHelper.UNINSTALL_PROTECT_BUTTON_SETTING)) {
                        Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
                        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdminSample);
                        intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, mContext.getString(R.string.enable_device_manager_declare));
                        mContext.startActivity(intent);
                    }
                }
            } else {
                **mDPM.removeActiveAdmin(mDeviceAdminSample);**
                Toast.makeText(mContext, "Device Administrator is disabled.", Toast.LENGTH_SHORT).show();
            }