RestrictionEntry
public
class
RestrictionEntry
extends Object
implements
Parcelable
java.lang.Object | |
↳ | android.content.RestrictionEntry |
Applications can expose restrictions for a restricted user on a multiuser device. The administrator can configure these restrictions that will then be applied to the restricted user. Each RestrictionsEntry is one configurable restriction.
Any application that chooses to expose such restrictions does so by implementing a receiver that handles theIntent#ACTION_GET_RESTRICTION_ENTRIES
action.
The receiver then returns a result bundle that contains an entry called "restrictions", whose
value is an ArrayListSummary
Constants | |
---|---|
int |
TYPE_BOOLEAN
Restriction of type "bool". |
int |
TYPE_BUNDLE
Restriction of type "bundle". |
int |
TYPE_BUNDLE_ARRAY
Restriction of type "bundle_array". |
int |
TYPE_CHOICE
Restriction of type "choice". |
int |
TYPE_INTEGER
Restriction of type "integer". |
int |
TYPE_MULTI_SELECT
Restriction of type "multi-select". |
int |
TYPE_NULL
Hidden restriction type. |
int |
TYPE_STRING
Restriction of type "string". |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<RestrictionEntry> |
CREATOR
|
Public constructors | |
---|---|
RestrictionEntry(int type, String key)
Constructor for specifying the type and key, with no initial value; |
|
RestrictionEntry(String key, String selectedString)
Constructor for |
|
RestrictionEntry(String key, boolean selectedState)
Constructor for |
|
RestrictionEntry(String key, String[] selectedStrings)
Constructor for |
|
RestrictionEntry(String key, int selectedInt)
Constructor for |
|
RestrictionEntry(Parcel in)
|
Public methods | |
---|---|
static
RestrictionEntry
|
createBundleArrayEntry(String key, RestrictionEntry[] restrictionEntries)
Creates an entry of type |
static
RestrictionEntry
|
createBundleEntry(String key, RestrictionEntry[] restrictionEntries)
Creates an entry of type |
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
boolean
|
equals(Object o)
Indicates whether some other object is "equal to" this one. |
String[]
|
getAllSelectedStrings()
Returns the list of currently selected values. |
String[]
|
getChoiceEntries()
Returns the list of strings, set earlier, that will be presented as choices to the user. |
String[]
|
getChoiceValues()
Returns the list of possible string values set earlier. |
String
|
getDescription()
Returns the provided user-visible description of the entry, if any. |
int
|
getIntValue()
Returns the value of the entry as an integer when the type is |
String
|
getKey()
This is the unique key for the restriction entry. |
RestrictionEntry[]
|
getRestrictions()
Returns array of possible restriction entries that this entry may contain. |
boolean
|
getSelectedState()
Returns the current selected state for an entry of type |
String
|
getSelectedString()
Returns the currently selected string value. |
String
|
getTitle()
Returns the user-visible title for the entry, if any. |
int
|
getType()
Returns the type for this restriction. |
int
|
hashCode()
Returns a hash code value for the object. |
void
|
setAllSelectedStrings(String[] allSelectedStrings)
Sets the current list of selected values for an entry of type |
void
|
setChoiceEntries(Context context, int stringArrayResId)
Sets a list of strings that will be presented as choices to the user. |
void
|
setChoiceEntries(String[] choiceEntries)
Sets a list of strings that will be presented as choices to the user. |
void
|
setChoiceValues(String[] choiceValues)
Sets a list of string values that can be selected by the user. |
void
|
setChoiceValues(Context context, int stringArrayResId)
Sets a list of string values that can be selected by the user, similar to
|
void
|
setDescription(String description)
Sets the user-visible description of the entry, as a possible sub-text for the title. |
void
|
setIntValue(int value)
Sets the integer value of the entry when the type is |
void
|
setRestrictions(RestrictionEntry[] restrictions)
Sets an array of possible restriction entries, that this entry may contain. |
void
|
setSelectedState(boolean state)
Sets the current selected state for an entry of type |
void
|
setSelectedString(String selectedString)
Sets the string value to use as the selected value for this restriction. |
void
|
setTitle(String title)
Sets the user-visible title for the entry. |
void
|
setType(int type)
Sets the type for this restriction. |
String
|
toString()
Returns a string representation of the object. |
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
---|---|
Constants
TYPE_BOOLEAN
public static final int TYPE_BOOLEAN
Restriction of type "bool". Use this for storing a boolean value, typically presented as a checkbox in the UI.
Constant Value: 1 (0x00000001)
TYPE_BUNDLE
public static final int TYPE_BUNDLE
Restriction of type "bundle". Use this for storing bundles
of
restrictions
Constant Value: 7 (0x00000007)
TYPE_BUNDLE_ARRAY
public static final int TYPE_BUNDLE_ARRAY
Restriction of type "bundle_array". Use this for storing arrays of
bundles
of restrictions
Constant Value: 8 (0x00000008)
TYPE_CHOICE
public static final int TYPE_CHOICE
Restriction of type "choice". Use this for storing a string value, typically presented as
a single-select list. Call setChoiceEntries(java.lang.String[])
and
setChoiceValues(java.lang.String[])
to set the localized list entries to present to the user
and the corresponding values, respectively.
Constant Value: 2 (0x00000002)
TYPE_INTEGER
public static final int TYPE_INTEGER
Restriction of type "integer". Use this for storing an integer value. The range of values
is from Integer#MIN_VALUE
to Integer#MAX_VALUE
.
Constant Value: 5 (0x00000005)
TYPE_MULTI_SELECT
public static final int TYPE_MULTI_SELECT
Restriction of type "multi-select". Use this for presenting a multi-select list where more
than one entry can be selected, such as for choosing specific titles to allowlist.
Call setChoiceEntries(java.lang.String[])
and
setChoiceValues(java.lang.String[])
to set the localized list entries to present to the user
and the corresponding values, respectively.
Use getAllSelectedStrings()
and setAllSelectedStrings(java.lang.String[])
to
manipulate the selections.
Constant Value: 4 (0x00000004)
TYPE_NULL
public static final int TYPE_NULL
Hidden restriction type. Use this type for information that needs to be transferred across but shouldn't be presented to the user in the UI. Stores a single String value.
Constant Value: 0 (0x00000000)
TYPE_STRING
public static final int TYPE_STRING
Restriction of type "string". Use this for storing a string value.
Constant Value: 6 (0x00000006)
Fields
Public constructors
RestrictionEntry
public RestrictionEntry (int type, String key)
Constructor for specifying the type and key, with no initial value;
Parameters | |
---|---|
type |
int : the restriction type. |
key |
String : the unique key for this restriction |
RestrictionEntry
public RestrictionEntry (String key, String selectedString)
Constructor for TYPE_CHOICE
type.
Parameters | |
---|---|
key |
String : the unique key for this restriction |
selectedString |
String : the current value |
RestrictionEntry
public RestrictionEntry (String key, boolean selectedState)
Constructor for TYPE_BOOLEAN
type.
Parameters | |
---|---|
key |
String : the unique key for this restriction |
selectedState |
boolean : whether this restriction is selected or not |
RestrictionEntry
public RestrictionEntry (String key, String[] selectedStrings)
Constructor for TYPE_MULTI_SELECT
type.
Parameters | |
---|---|
key |
String : the unique key for this restriction |
selectedStrings |
String : the list of values that are currently selected |
RestrictionEntry
public RestrictionEntry (String key, int selectedInt)
Constructor for TYPE_INTEGER
type.
Parameters | |
---|---|
key |
String : the unique key for this restriction |
selectedInt |
int : the integer value of the restriction |
Public methods
createBundleArrayEntry
public static RestrictionEntry createBundleArrayEntry (String key, RestrictionEntry[] restrictionEntries)
Creates an entry of type TYPE_BUNDLE_ARRAY
.
Parameters | |
---|---|
key |
String : the unique key for this restriction |
restrictionEntries |
RestrictionEntry : array of nested restriction entries. The array may only contain
elements of type bundle . |
Returns | |
---|---|
RestrictionEntry |
the newly created restriction |
createBundleEntry
public static RestrictionEntry createBundleEntry (String key, RestrictionEntry[] restrictionEntries)
Creates an entry of type TYPE_BUNDLE
.
Parameters | |
---|---|
key |
String : the unique key for this restriction |
restrictionEntries |
RestrictionEntry : array of nested restriction entries. |
Returns | |
---|---|
RestrictionEntry |
the newly created restriction |
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(android.os.Parcel, int)
,
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR
bit.
Returns | |
---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
equals
public boolean equals (Object o)
Indicates whether some other object is "equal to" this one.
The equals
method implements an equivalence relation
on non-null object references:
- It is reflexive: for any non-null reference value
x
,x.equals(x)
should returntrue
. - It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified. - For any non-null reference value
x
,x.equals(null)
should returnfalse
.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
Parameters | |
---|---|
o |
Object : This value may be null . |
Returns | |
---|---|
boolean |
true if this object is the same as the obj
argument; false otherwise. |
getAllSelectedStrings
public String[] getAllSelectedStrings ()
Returns the list of currently selected values.
Returns | |
---|---|
String[] |
the list of current selections, if type is TYPE_MULTI_SELECT ,
null otherwise. |
getChoiceEntries
public String[] getChoiceEntries ()
Returns the list of strings, set earlier, that will be presented as choices to the user.
Returns | |
---|---|
String[] |
the list of choices presented to the user. |
getChoiceValues
public String[] getChoiceValues ()
Returns the list of possible string values set earlier.
Returns | |
---|---|
String[] |
the list of possible values. |
getDescription
public String getDescription ()
Returns the provided user-visible description of the entry, if any.
Returns | |
---|---|
String |
the user-visible description, null if none was set earlier. |
getIntValue
public int getIntValue ()
Returns the value of the entry as an integer when the type is TYPE_INTEGER
.
Returns | |
---|---|
int |
the integer value of the entry. |
getKey
public String getKey ()
This is the unique key for the restriction entry.
Returns | |
---|---|
String |
the key for the restriction. |
getRestrictions
public RestrictionEntry[] getRestrictions ()
Returns array of possible restriction entries that this entry may contain.
Returns | |
---|---|
RestrictionEntry[] |
getSelectedState
public boolean getSelectedState ()
Returns the current selected state for an entry of type TYPE_BOOLEAN
.
Returns | |
---|---|
boolean |
the current selected state of the entry. |
getSelectedString
public String getSelectedString ()
Returns the currently selected string value.
Returns | |
---|---|
String |
the currently selected value, which can be null for types that aren't for holding single string values. |
getTitle
public String getTitle ()
Returns the user-visible title for the entry, if any.
Returns | |
---|---|
String |
the user-visible title for the entry, null if none was set earlier. |
getType
public int getType ()
Returns the type for this restriction.
Returns | |
---|---|
int |
the type for this restriction |
hashCode
public int hashCode ()
Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
HashMap
.
The general contract of hashCode
is:
- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
hashCode
method must consistently return the same integer, provided no information used inequals
comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. - If two objects are equal according to the
equals
method, then calling thehashCode
method on each of the two objects must produce the same integer result. - It is not required that if two objects are unequal
according to the
equals
method, then calling thehashCode
method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns | |
---|---|
int |
a hash code value for this object. |
setAllSelectedStrings
public void setAllSelectedStrings (String[] allSelectedStrings)
Sets the current list of selected values for an entry of type TYPE_MULTI_SELECT
.
These values will be persisted by the system for later use by the application.
Parameters | |
---|---|
allSelectedStrings |
String : the current list of selected values. |
setChoiceEntries
public void setChoiceEntries (Context context, int stringArrayResId)
Sets a list of strings that will be presented as choices to the user. This is similar to
setChoiceEntries(java.lang.String[])
.
Parameters | |
---|---|
context |
Context : the application context, used for retrieving the resources. |
stringArrayResId |
int : the resource id of a string array containing the possible entries. |
setChoiceEntries
public void setChoiceEntries (String[] choiceEntries)
Sets a list of strings that will be presented as choices to the user. When the
user selects one or more of these choices, the corresponding value from the possible values
are stored as the selected strings. The size of this array must match the size of the array
set in setChoiceValues(java.lang.String[])
. This method is not relevant for types other
than TYPE_CHOICE
, and TYPE_MULTI_SELECT
.
Parameters | |
---|---|
choiceEntries |
String : the list of user-visible choices. |
See also:
setChoiceValues
public void setChoiceValues (String[] choiceValues)
Sets a list of string values that can be selected by the user. If no user-visible entries
are set by a call to setChoiceEntries(java.lang.String[])
, these values will be the ones
shown to the user. Values will be chosen from this list as the user's selection and the
selected values can be retrieved by a call to getAllSelectedStrings()
, or
getSelectedString()
, depending on whether it is a multi-select type or choice type.
This method is not relevant for types other than
TYPE_CHOICE
, and TYPE_MULTI_SELECT
.
Parameters | |
---|---|
choiceValues |
String : an array of Strings which will be the selected values for the user's
selections. |
See also:
setChoiceValues
public void setChoiceValues (Context context, int stringArrayResId)
Sets a list of string values that can be selected by the user, similar to
setChoiceValues(java.lang.String[])
.
Parameters | |
---|---|
context |
Context : the application context for retrieving the resources. |
stringArrayResId |
int : the resource id for a string array containing the possible values. |
See also:
setDescription
public void setDescription (String description)
Sets the user-visible description of the entry, as a possible sub-text for the title. You can use this to describe the entry in more detail or to display the current state of the restriction.
Parameters | |
---|---|
description |
String : the user-visible description string. |
setIntValue
public void setIntValue (int value)
Sets the integer value of the entry when the type is TYPE_INTEGER
.
Parameters | |
---|---|
value |
int : the integer value to set. |
setRestrictions
public void setRestrictions (RestrictionEntry[] restrictions)
Sets an array of possible restriction entries, that this entry may contain.
This method is only relevant for types TYPE_BUNDLE
and
TYPE_BUNDLE_ARRAY
Parameters | |
---|---|
restrictions |
RestrictionEntry |
setSelectedState
public void setSelectedState (boolean state)
Sets the current selected state for an entry of type TYPE_BOOLEAN
. This value will
be persisted by the system for later use by the application.
Parameters | |
---|---|
state |
boolean : the current selected state |
setSelectedString
public void setSelectedString (String selectedString)
Sets the string value to use as the selected value for this restriction. This value will be persisted by the system for later use by the application.
Parameters | |
---|---|
selectedString |
String : the string value to select. |
setTitle
public void setTitle (String title)
Sets the user-visible title for the entry.
Parameters | |
---|---|
title |
String : the user-visible title for the entry. |
setType
public void setType (int type)
Sets the type for this restriction.
Parameters | |
---|---|
type |
int : the type for this restriction. |
toString
public String toString ()
Returns a string representation of the object.
Returns | |
---|---|
String |
a string representation of the object. |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
Parameters | |
---|---|
dest |
Parcel : The Parcel in which the object should be written.
This value cannot be null . |
flags |
int : Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |