Udostępnij za pośrednictwem


RestrictionsManager Class

Definition

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

[Android.Runtime.Register("android/content/RestrictionsManager", DoNotGenerateAcw=true)]
public class RestrictionsManager : Java.Lang.Object
[<Android.Runtime.Register("android/content/RestrictionsManager", DoNotGenerateAcw=true)>]
type RestrictionsManager = class
    inherit Object
Inheritance
RestrictionsManager
Attributes

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 #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, #ACTION_PERMISSION_RESPONSE_RECEIVED.

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:

&lt;?xml version="1.0" encoding="utf-8"?&gt;
            &lt;restrictions xmlns:android="http://schemas.android.com/apk/res/android" &gt;
                &lt;restriction
                    android:key="string"
                    android:title="string resource"
                    android:restrictionType=["bool" | "string" | "integer"
                                                    | "choice" | "multi-select" | "hidden"
                                                    | "bundle" | "bundle_array"]
                    android:description="string resource"
                    android:entries="string-array resource"
                    android:entryValues="string-array resource"
                    android:defaultValue="reference" &gt;
                        &lt;restriction ... /&gt;
                        ...
                &lt;/restriction&gt;
                &lt;restriction ... /&gt;
                ...
            &lt;/restrictions&gt;

The attributes for each restriction depend on the restriction type.

<ul> <li>key, title and restrictionType are mandatory.</li> <li>entries and entryValues are required if restrictionType is choice or multi-select.</li> <li>defaultValue is optional and its type depends on the restrictionType</li> <li>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.</li> <li>description is meant to describe the restriction in more detail to the administrator controlling the values, if the title is not sufficient.</li> </ul>

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:

&lt;application ... &gt;
                &lt;meta-data android:name="android.content.APP_RESTRICTIONS"
                              android:resource="@xml/app_restrictions" /&gt;
                ...
            &lt;/application&gt;

Java documentation for android.content.RestrictionsManager.

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.

Constructors

RestrictionsManager(IntPtr, JniHandleOwnership)

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

Fields

ActionPermissionResponseReceived

Broadcast intent delivered when a response is received for a permission request.

ActionRequestLocalApproval

Activity intent that is optionally implemented by the Restrictions Provider package to challenge for an administrator PIN or password locally on the device.

ActionRequestPermission

Broadcast intent sent to the Restrictions Provider to handle a permission request from an app.

ExtraPackageName

The package name of the application making the request.

ExtraRequestBundle

The request bundle passed in the #ACTION_REQUEST_PERMISSION broadcast.

ExtraRequestId

The request ID passed in the #ACTION_REQUEST_PERMISSION broadcast.

ExtraRequestType

The request type passed in the #ACTION_REQUEST_PERMISSION broadcast.

ExtraResponseBundle

Contains a response from the administrator for specific request.

MetaDataAppRestrictions

Name of the meta-data entry in the manifest that points to the XML file containing the application's available restrictions.

RequestKeyApproveLabel

Key for request approval button label contained in the request bundle.

RequestKeyData

Key for request data contained in the request bundle.

RequestKeyDenyLabel

Key for request rejection button label contained in the request bundle.

RequestKeyIcon

Key for request icon contained in the request bundle.

RequestKeyId

Key for request ID contained in the request bundle.

RequestKeyMessage

Key for request message contained in the request bundle.

RequestKeyNewRequest

Key for issuing a new request, contained in the request bundle.

RequestKeyTitle

Key for request title contained in the request bundle.

RequestTypeApproval

Request type for a simple question, with a possible title and icon.

ResponseKeyErrorCode

Key for the optional error code in the response bundle sent to the application.

ResponseKeyMessage

Key for the optional message in the response bundle sent to the application.

ResponseKeyResponseTimestamp

Key for the optional timestamp of when the administrator responded to the permission request.

ResponseKeyResult

Key for the response result in the response bundle sent to the application, for a permission request.

Properties

ApplicationRestrictions

Returns any available set of application-specific restrictions applicable to this application.

ApplicationRestrictionsPerAdmin

Returns a List containing a Bundle for each managing agent that has set restrictions for the current application, the bundle contains any application restrictions set for the current package.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
HasRestrictionsProvider

Called by an application to check if there is an active Restrictions Provider.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
ConvertRestrictionsToBundle(IList<RestrictionEntry>)

Converts a list of restrictions to the corresponding bundle, using the following mapping: <table> <tr><th>RestrictionEntry</th><th>Bundle</th></tr> <tr><td>RestrictionEntry#TYPE_BOOLEAN</td><td>Bundle#putBoolean</td></tr> <tr><td>RestrictionEntry#TYPE_CHOICE, RestrictionEntry#TYPE_MULTI_SELECT</td> <td>Bundle#putStringArray</td></tr> <tr><td>RestrictionEntry#TYPE_INTEGER</td><td>Bundle#putInt</td></tr> <tr><td>RestrictionEntry#TYPE_STRING</td><td>Bundle#putString</td></tr> <tr><td>RestrictionEntry#TYPE_BUNDLE</td><td>Bundle#putBundle</td></tr> <tr><td>RestrictionEntry#TYPE_BUNDLE_ARRAY</td> <td>Bundle#putParcelableArray</td></tr> </table>

CreateLocalApprovalIntent()
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetManifestRestrictions(String)

Parse and return the list of restrictions defined in the manifest for the specified package, if any.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
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.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to