Language

UserManager.GetApplicationRestrictions(String) Method

Definition

Returns a Bundle containing any saved application restrictions for the context user, for the given package name.

[Android.Runtime.Register("getApplicationRestrictions", "(Ljava/lang/String;)Landroid/os/Bundle;", "GetGetApplicationRestrictions_Ljava_lang_String_Handler")]
public virtual Android.OS.Bundle? GetApplicationRestrictions(string? packageName);
[<Android.Runtime.Register("getApplicationRestrictions", "(Ljava/lang/String;)Landroid/os/Bundle;", "GetGetApplicationRestrictions_Ljava_lang_String_Handler")>]
abstract member GetApplicationRestrictions : string -> Android.OS.Bundle
override this.GetApplicationRestrictions : string -> Android.OS.Bundle

Parameters

packageName
String

the package name of the calling application

Returns

a Bundle with the restrictions for that package, or an empty Bundle if there are no saved restrictions.

Attributes

Remarks

Returns a Bundle containing any saved application restrictions for the context user, for the given package name. Only an application with this package name can call this method.

The returned Bundle consists of key-value pairs, as defined by the application, 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>

NOTE: The method performs disk I/O and shouldn't be called on the main thread

Starting from Android version android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE, it is possible for there to be multiple managing apps on the device with the ability to set app restrictions, e.g. an Enterprise Device Policy Controller (DPC) and a Supervision admin. This method will always return the app restrictions set by the DPC, if the DPC has set one. Beginning from SDK level 36.1, if the DPC has not set any app restriction while other managing apps have set some, this method will return app restrictions set by one of those managing apps. There is no guarantee on which managing apps app restriction will be returned. To retrieve restrictions set by all managing apps, use android.content.RestrictionsManager#getApplicationRestrictionsPerAdmin instead.

Java documentation for android.os.UserManager.getApplicationRestrictions(java.lang.String).

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.

Applies to