Android APIs
public final class

InputMethodSubtype

extends Object
implements Parcelable
java.lang.Object
   ↳ android.view.inputmethod.InputMethodSubtype

Class Overview

This class is used to specify meta information of a subtype contained in an input method editor (IME). Subtype can describe locale (e.g. en_US, fr_FR...) and mode (e.g. voice, keyboard...), and is used for IME switch and settings. The input method subtype allows the system to bring up the specified subtype of the designated IME directly.

It should be defined in an XML resource file of the input method with the <subtype> element, which resides within an <input-method> element. For more information, see the guide to Creating an Input Method.

See Also

Summary

Nested Classes
class InputMethodSubtype.InputMethodSubtypeBuilder InputMethodSubtypeBuilder is a builder class of InputMethodSubtype. 
XML Attributes
Attribute Name Related Method Description
android:icon The icon of the subtype. 
android:imeSubtypeExtraValue The extra value of the subtype. 
android:imeSubtypeLocale The locale of the subtype. 
android:imeSubtypeMode The mode of the subtype. 
android:isAsciiCapable Set to true if this subtype is ASCII capable. 
android:isAuxiliary Set true if the subtype is auxiliary. 
android:label The name of the subtype. 
android:overridesImplicitlyEnabledSubtype Set true when this subtype should be selected by default if no other subtypes are selected explicitly. 
android:subtypeId The unique id for the subtype. 
[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<InputMethodSubtype> CREATOR
Public Constructors
InputMethodSubtype(int nameId, int iconId, String locale, String mode, String extraValue, boolean isAuxiliary, boolean overridesImplicitlyEnabledSubtype)
This constructor was deprecated in API level 19. use InputMethodSubtype.InputMethodSubtypeBuilder instead. Arguments for this constructor have the same meanings as InputMethodSubtype(int, int, String, String, String, boolean, boolean, int) except "id".
InputMethodSubtype(int nameId, int iconId, String locale, String mode, String extraValue, boolean isAuxiliary, boolean overridesImplicitlyEnabledSubtype, int id)
This constructor was deprecated in API level 19. use InputMethodSubtype.InputMethodSubtypeBuilder instead. "isAsciiCapable" is "false" in this constructor.
Public Methods
boolean containsExtraValueKey(String key)
The string of ExtraValue in subtype should be defined as follows: example: key0,key1=value1,key2,key3,key4=value4
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
boolean equals(Object o)
Compares this instance with the specified object and indicates if they are equal.
CharSequence getDisplayName(Context context, String packageName, ApplicationInfo appInfo)
String getExtraValue()
String getExtraValueOf(String key)
The string of ExtraValue in subtype should be defined as follows: example: key0,key1=value1,key2,key3,key4=value4
int getIconResId()
String getLocale()
String getMode()
int getNameResId()
int hashCode()
Returns an integer hash code for this object.
boolean isAsciiCapable()
boolean isAuxiliary()
boolean overridesImplicitlyEnabledSubtype()
void writeToParcel(Parcel dest, int parcelableFlags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

XML Attributes

android:icon

The icon of the subtype.

Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".

This corresponds to the global attribute resource symbol icon.

Related Methods

android:imeSubtypeExtraValue

The extra value of the subtype. This string can be any string and will be passed to the IME when the framework calls the IME with the subtype.

Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol imeSubtypeExtraValue.

Related Methods

android:imeSubtypeLocale

The locale of the subtype. This string should be a locale (e.g. en_US, fr_FR...) and will be passed to the IME when the framework calls the IME with the subtype. This is also used by the framework to know the supported locales of the IME.

Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol imeSubtypeLocale.

Related Methods

android:imeSubtypeMode

The mode of the subtype. This string can be a mode (e.g. voice, keyboard...) and this string will be passed to the IME when the framework calls the IME with the subtype.

Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol imeSubtypeMode.

Related Methods

android:isAsciiCapable

Set to true if this subtype is ASCII capable. If the subtype is ASCII capable, it should guarantee that the user can input ASCII characters with this subtype. This is important because many password fields only allow ASCII-characters.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol isAsciiCapable.

Related Methods

android:isAuxiliary

Set true if the subtype is auxiliary. An auxiliary subtype won't be shown in the input method selection list in the settings app. InputMethodManager#switchToLastInputMethod will ignore auxiliary subtypes when it chooses a target subtype.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol isAuxiliary.

Related Methods

android:label

The name of the subtype.

May be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.

This corresponds to the global attribute resource symbol label.

Related Methods

android:overridesImplicitlyEnabledSubtype

Set true when this subtype should be selected by default if no other subtypes are selected explicitly. Note that a subtype with this parameter being true will not be shown in the subtypes list.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol overridesImplicitlyEnabledSubtype.

Related Methods

android:subtypeId

The unique id for the subtype. The input method framework keeps track of enabled subtypes by ID. When the IME package gets upgraded, enabled IDs will stay enabled even if other attributes are different. If the ID is unspecified (by calling the other constructor or 0. Arrays.hashCode(new Object[] {locale, mode, extraValue, isAuxiliary, overridesImplicitlyEnabledSubtype}) will be used instead.

Must be an integer value, such as "100".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol subtypeId.

Related Methods

Fields

public static final Creator<InputMethodSubtype> CREATOR

Added in API level 11

Public Constructors

public InputMethodSubtype (int nameId, int iconId, String locale, String mode, String extraValue, boolean isAuxiliary, boolean overridesImplicitlyEnabledSubtype)

Added in API level 14

This constructor was deprecated in API level 19.
use InputMethodSubtype.InputMethodSubtypeBuilder instead. Arguments for this constructor have the same meanings as InputMethodSubtype(int, int, String, String, String, boolean, boolean, int) except "id".

Constructor with no subtype ID specified.

public InputMethodSubtype (int nameId, int iconId, String locale, String mode, String extraValue, boolean isAuxiliary, boolean overridesImplicitlyEnabledSubtype, int id)

Added in API level 17

This constructor was deprecated in API level 19.
use InputMethodSubtype.InputMethodSubtypeBuilder instead. "isAsciiCapable" is "false" in this constructor.

Constructor.

Parameters
nameId Resource ID of the subtype name string. The string resource may have exactly one %s in it. If there is, the %s part will be replaced with the locale's display name by the formatter. Please refer to getDisplayName(Context, String, ApplicationInfo) for details.
iconId Resource ID of the subtype icon drawable.
locale The locale supported by the subtype
mode The mode supported by the subtype
extraValue The extra value of the subtype. This string is free-form, but the API supplies tools to deal with a key-value comma-separated list; see containsExtraValueKey(String) and getExtraValueOf(String).
isAuxiliary true when this subtype is auxiliary, false otherwise. An auxiliary subtype will not be shown in the list of enabled IMEs for choosing the current IME in the Settings even when this subtype is enabled. Please note that this subtype will still be shown in the list of IMEs in the IME switcher to allow the user to tentatively switch to this subtype while an IME is shown. The framework will never switch the current IME to this subtype by switchToLastInputMethod(IBinder). The intent of having this flag is to allow for IMEs that are invoked in a one-shot way as auxiliary input mode, and return to the previous IME once it is finished (e.g. voice input).
overridesImplicitlyEnabledSubtype true when this subtype should be enabled by default if no other subtypes in the IME are enabled explicitly. Note that a subtype with this parameter being true will not be shown in the list of subtypes in each IME's subtype enabler. Having an "automatic" subtype is an example use of this flag.
id The unique ID for the subtype. The input method framework keeps track of enabled subtypes by ID. When the IME package gets upgraded, enabled IDs will stay enabled even if other attributes are different. If the ID is unspecified or 0, Arrays.hashCode(new Object[] {locale, mode, extraValue, isAuxiliary, overridesImplicitlyEnabledSubtype}) will be used instead.

Public Methods

public boolean containsExtraValueKey (String key)

Added in API level 12

The string of ExtraValue in subtype should be defined as follows: example: key0,key1=value1,key2,key3,key4=value4

Parameters
key The key of extra value
Returns
  • The subtype contains specified the extra value

public int describeContents ()

Added in API level 11

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public boolean equals (Object o)

Added in API level 11

Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.

The default implementation returns true only if this == o. See Writing a correct equals method if you intend implementing your own equals method.

The general contract for the equals and hashCode() methods is that if equals returns true for any two objects, then hashCode() must return the same value for these objects. This means that subclasses of Object usually override either both methods or neither of them.

Parameters
o the object to compare this instance with.
Returns
  • true if the specified object is equal to this Object; false otherwise.

public CharSequence getDisplayName (Context context, String packageName, ApplicationInfo appInfo)

Added in API level 14

Parameters
context Context will be used for getting Locale and PackageManager.
packageName The package name of the IME
appInfo The application info of the IME
Returns
  • a display name for this subtype. The string resource of the label (mSubtypeNameResId) may have exactly one %s in it. If there is, the %s part will be replaced with the locale's display name by the formatter. If there is not, this method returns the string specified by mSubtypeNameResId. If mSubtypeNameResId is not specified (== 0), it's up to the framework to generate an appropriate display name.

public String getExtraValue ()

Added in API level 11

Returns
  • The extra value of the subtype.

public String getExtraValueOf (String key)

Added in API level 12

The string of ExtraValue in subtype should be defined as follows: example: key0,key1=value1,key2,key3,key4=value4

Parameters
key The key of extra value
Returns
  • The value of the specified key

public int getIconResId ()

Added in API level 11

Returns
  • Resource ID of the subtype icon drawable.

public String getLocale ()

Added in API level 11

Returns
  • The locale of the subtype. This method returns the "locale" string parameter passed to the constructor.

public String getMode ()

Added in API level 11

Returns
  • The mode of the subtype.

public int getNameResId ()

Added in API level 11

Returns
  • Resource ID of the subtype name string.

public int hashCode ()

Added in API level 11

Returns an integer hash code for this object. By contract, any two objects for which equals(Object) returns true must return the same hash code value. This means that subclasses of Object usually override both methods or neither method.

Note that hash values must not change over time unless information used in equals comparisons also changes.

See Writing a correct hashCode method if you intend implementing your own hashCode method.

Returns
  • this object's hash code.

public boolean isAsciiCapable ()

Added in API level 19

Returns
  • true if this subtype is Ascii capable, false otherwise. If the subtype is ASCII capable, it should guarantee that the user can input ASCII characters with this subtype. This is important because many password fields only allow ASCII-characters.

public boolean isAuxiliary ()

Added in API level 14

Returns
  • true if this subtype is auxiliary, false otherwise. An auxiliary subtype will not be shown in the list of enabled IMEs for choosing the current IME in the Settings even when this subtype is enabled. Please note that this subtype will still be shown in the list of IMEs in the IME switcher to allow the user to tentatively switch to this subtype while an IME is shown. The framework will never switch the current IME to this subtype by switchToLastInputMethod(IBinder). The intent of having this flag is to allow for IMEs that are invoked in a one-shot way as auxiliary input mode, and return to the previous IME once it is finished (e.g. voice input).

public boolean overridesImplicitlyEnabledSubtype ()

Added in API level 14

Returns
  • true when this subtype will be enabled by default if no other subtypes in the IME are enabled explicitly, false otherwise. Note that a subtype with this method returning true will not be shown in the list of subtypes in each IME's subtype enabler. Having an "automatic" subtype is an example use of this flag.

public void writeToParcel (Parcel dest, int parcelableFlags)

Added in API level 11

Flatten this object in to a Parcel.

Parameters
dest The Parcel in which the object should be written.
parcelableFlags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.