Android Guides | Samples

Android.Content.RestrictionsManager Class

Provides a mechanism for apps to query restrictions imposed by an entity that manages the user.

See Also: RestrictionsManager

Syntax

[Android.Runtime.Register("android/content/RestrictionsManager", DoNotGenerateAcw=true)]
public class RestrictionsManager : Object

Remarks

Provides a mechanism for apps to query restrictions imposed by an entity that manages the user. Apps can also send permission requests to a local or remote device administrator to override default app-specific restrictions or any other operation that needs explicit authorization from the administrator.

Apps can expose a set of restrictions via an XML file specified in the manifest.

If the user has an active Restrictions Provider, dynamic requests can be made in addition to the statically imposed restrictions. Dynamic requests are app-specific and can be expressed via a predefined set of request types.

The RestrictionsManager forwards the dynamic requests to the active Restrictions Provider. The Restrictions Provider can respond back to requests by calling RestrictionsManager.NotifyPermissionResponse(String,PersistableBundle), when a response is received from the administrator of the device or user. The response is relayed back to the application via a protected broadcast, RestrictionsManager.ActionPermissionResponseReceived.

Static restrictions are specified by an XML file referenced by a meta-data attribute in the manifest. This enables applications as well as any web administration consoles to be able to read the list of available restrictions from the apk.

The syntax of the XML format is as follows:

The attributes for each restriction depend on the restriction type.

  • key, title and restrictionType are mandatory.
  • entries and entryValues are required if restrictionType is choice or multi-select.
  • defaultValue is optional and its type depends on the restrictionType
  • hidden type must have a defaultValue and will not be shown to the administrator. It can be used to pass along data that cannot be modified, such as a version code.
  • description is meant to describe the restriction in more detail to the administrator controlling the values, if the title is not sufficient.

Only restrictions of type bundle and bundle_array can have one or multiple nested restriction elements.

In your manifest's application section, add the meta-data tag to point to the restrictions XML file as shown below:

See Also

[Android Documentation]

Requirements

Namespace: Android.Content
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0

The members of Android.Content.RestrictionsManager are listed below.

See Also: Object

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Fields

const
ActionPermissionResponseReceivedString. Broadcast intent delivered when a response is received for a permission request.
const
ActionRequestLocalApprovalString. Activity intent that is optionally implemented by the Restrictions Provider package to challenge for an administrator PIN or password locally on the device.
const
ActionRequestPermissionString. Broadcast intent sent to the Restrictions Provider to handle a permission request from an app.
const
ExtraPackageNameString. The package name of the application making the request.
const
ExtraRequestBundleString. The request bundle passed in the RestrictionsManager.ActionRequestPermission broadcast.
const
ExtraRequestIdString. The request ID passed in the RestrictionsManager.ActionRequestPermission broadcast.
const
ExtraRequestTypeString. The request type passed in the RestrictionsManager.ActionRequestPermission broadcast.
const
ExtraResponseBundleString. Contains a response from the administrator for specific request.
const
MetaDataAppRestrictionsString. Name of the meta-data entry in the manifest that points to the XML file containing the application's available restrictions.
const
RequestKeyApproveLabelString. Key for request approval button label contained in the request bundle.
const
RequestKeyDataString. Key for request data contained in the request bundle.
const
RequestKeyDenyLabelString. Key for request rejection button label contained in the request bundle.
const
RequestKeyIconString. Key for request icon contained in the request bundle.
const
RequestKeyIdString. Key for request ID contained in the request bundle.
const
RequestKeyMessageString. Key for request message contained in the request bundle.
const
RequestKeyNewRequestString. Key for issuing a new request, contained in the request bundle.
const
RequestKeyTitleString. Key for request title contained in the request bundle.
const
RequestTypeApprovalString. Request type for a simple question, with a possible title and icon.
const
ResponseKeyErrorCodeString. Key for the optional error code in the response bundle sent to the application.
const
ResponseKeyMessageString. Key for the optional message in the response bundle sent to the application.
const
ResponseKeyResponseTimestampString. Key for the optional timestamp of when the administrator responded to the permission request.
const
ResponseKeyResultString. Key for the response result in the response bundle sent to the application, for a permission request.

Public Properties

[read-only]
ApplicationRestrictionsBundle. Returns any available set of application-specific restrictions applicable to this application.
[read-only]
HasRestrictionsProviderBoolean. Called by an application to check if there is an active Restrictions Provider.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

CreateLocalApprovalIntent() : Intent
GetManifestRestrictions(String) : IList<RestrictionEntry>
Parse and return the list of restrictions defined in the manifest for the specified package, if any.
NotifyPermissionResponse(String, PersistableBundle)
Called by the Restrictions Provider to deliver a response to an application.
RequestPermission(String, String, PersistableBundle)
Called by an application to request permission for an operation.