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();
}