List of usage examples for android.app.admin DevicePolicyManager PERMISSION_POLICY_AUTO_DENY
int PERMISSION_POLICY_AUTO_DENY
To view the source code for android.app.admin DevicePolicyManager PERMISSION_POLICY_AUTO_DENY.
Click Source Link
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
/** * Shows the default response for future runtime permission requests by applications, and lets * the user change the default value./*from w w w.j a v a2 s .co m*/ */ @TargetApi(Build.VERSION_CODES.M) private void showSetPermissionPolicyDialog() { if (getActivity() == null || getActivity().isFinishing()) { return; } View setPermissionPolicyView = getActivity().getLayoutInflater().inflate(R.layout.set_permission_policy, null); final RadioGroup permissionGroup = (RadioGroup) setPermissionPolicyView .findViewById(R.id.set_permission_group); int permissionPolicy = mDevicePolicyManager.getPermissionPolicy(mAdminComponentName); switch (permissionPolicy) { case DevicePolicyManager.PERMISSION_POLICY_PROMPT: ((RadioButton) permissionGroup.findViewById(R.id.prompt)).toggle(); break; case DevicePolicyManager.PERMISSION_POLICY_AUTO_GRANT: ((RadioButton) permissionGroup.findViewById(R.id.accept)).toggle(); break; case DevicePolicyManager.PERMISSION_POLICY_AUTO_DENY: ((RadioButton) permissionGroup.findViewById(R.id.deny)).toggle(); break; } new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.set_default_permission_policy)) .setView(setPermissionPolicyView) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int policy = 0; int checked = permissionGroup.getCheckedRadioButtonId(); switch (checked) { case (R.id.prompt): policy = DevicePolicyManager.PERMISSION_POLICY_PROMPT; break; case (R.id.accept): policy = DevicePolicyManager.PERMISSION_POLICY_AUTO_GRANT; break; case (R.id.deny): policy = DevicePolicyManager.PERMISSION_POLICY_AUTO_DENY; break; } mDevicePolicyManager.setPermissionPolicy(mAdminComponentName, policy); dialog.dismiss(); } }).show(); }