DevicePolicyManager.SetApplicationRestrictions Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the application restrictions for a given target application running in the calling user.
[Android.Runtime.Register("setApplicationRestrictions", "(Landroid/content/ComponentName;Ljava/lang/String;Landroid/os/Bundle;)V", "GetSetApplicationRestrictions_Landroid_content_ComponentName_Ljava_lang_String_Landroid_os_Bundle_Handler")]
public virtual void SetApplicationRestrictions (Android.Content.ComponentName? admin, string? packageName, Android.OS.Bundle? settings);
[<Android.Runtime.Register("setApplicationRestrictions", "(Landroid/content/ComponentName;Ljava/lang/String;Landroid/os/Bundle;)V", "GetSetApplicationRestrictions_Landroid_content_ComponentName_Ljava_lang_String_Landroid_os_Bundle_Handler")>]
abstract member SetApplicationRestrictions : Android.Content.ComponentName * string * Android.OS.Bundle -> unit
override this.SetApplicationRestrictions : Android.Content.ComponentName * string * Android.OS.Bundle -> unit
Parameters
- admin
- ComponentName
Which DeviceAdminReceiver
this request is associated with, or
null
if called by the application restrictions managing package.
- packageName
- String
The name of the package to update restricted settings for.
- settings
- Bundle
A Bundle
to be parsed by the receiving application, conveying a new
set of active restrictions.
- Attributes
Remarks
Sets the application restrictions for a given target application running in the calling user.
The caller must be a profile or device owner on that user, or the package allowed to manage application restrictions via #setDelegatedScopes
with the #DELEGATION_APP_RESTRICTIONS
scope; otherwise a security exception will be thrown.
The provided Bundle
consists of key-value pairs, where the types of values may be: <ul> <li>boolean
<li>int
<li>String
or String[]
<li>From android.os.Build.VERSION_CODES#M
, Bundle
or Bundle[]
</ul>
If the restrictions are not available yet, but may be applied in the near future, the caller can notify the target application of that by adding UserManager#KEY_RESTRICTIONS_PENDING
to the settings parameter.
The application restrictions are only made visible to the target application via UserManager#getApplicationRestrictions(String)
, in addition to the profile or device owner, and the application restrictions managing package via #getApplicationRestrictions
.
Starting from Android Version android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE
, multiple admins can set app restrictions for the same application, the target application can get the list of app restrictions set by each admin via android.content.RestrictionsManager#getApplicationRestrictionsPerAdmin
.
NOTE: The method performs disk I/O and shouldn't be called on the main thread
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.