InputMethodSubtype
  public
  
  final
  
  class
  InputMethodSubtype
  
    extends Object
  
  
  
  
  
      implements
      
        Parcelable
      
  
  
| java.lang.Object | |
| ↳ | android.view.inputmethod.InputMethodSubtype | 
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.InputMethodSubtypeBuilderInputMethodSubtypeBuilder is a builder class of InputMethodSubtype. | 
| XML attributes | |
|---|---|
| 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 trueif this subtype is ASCII capable. | 
| android:isAuxiliary | Set true if the subtype is auxiliary. | 
| android:label | The name of the subtype. | 
| android:languageTag | The BCP-47 Language Tag of the subtype. | 
| android:overridesImplicitlyEnabledSubtype | Set true when this subtype should be selected by default if no other subtypes are selected explicitly. | 
| android:physicalKeyboardHintLanguageTag | The BCP-47 Language Tag of the preferred physical keyboard of the subtype. | 
| android:physicalKeyboardHintLayoutType | The layout type of the preferred physical keyboard of the subtype. | 
| android:subtypeId | The unique id for the subtype. | 
| Inherited constants | 
|---|
| 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 is deprecated.
    use  | |
| 
      InputMethodSubtype(int nameId, int iconId, String locale, String mode, String extraValue, boolean isAuxiliary, boolean overridesImplicitlyEnabledSubtype, int id)
      
      This constructor is deprecated.
    use  | |
| 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 instance's marshaled representation. | 
| 
        
        
        
        
        
        boolean | 
      equals(Object o)
      Indicates whether some other object is "equal to" this one. | 
| 
        
        
        
        
        
        CharSequence | 
      getDisplayName(Context context, String packageName, ApplicationInfo appInfo)
      Returns a display name for this subtype. | 
| 
        
        
        
        
        
        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 | 
      getLanguageTag()
       | 
| 
        
        
        
        
        
        CharSequence | 
      getLayoutDisplayName(Context context, ApplicationInfo imeAppInfo)
      Returns the layout display name. | 
| 
        
        
        
        
        
        CharSequence | 
      getLayoutLabelNonLocalized()
      Returns the non-localized layout label. | 
| 
        
        
        
        
        
        int | 
      getLayoutLabelResource()
      Returns the layout label string resource identifier. | 
| 
        
        
        
        
        
        String | 
      getLocale()
      
      This method was deprecated
      in API level 24.
    Use  | 
| 
        
        
        
        
        
        String | 
      getMode()
       | 
| 
        
        
        
        
        
        CharSequence | 
      getNameOverride()
       | 
| 
        
        
        
        
        
        int | 
      getNameResId()
       | 
| 
        
        
        
        
        
        ULocale | 
      getPhysicalKeyboardHintLanguageTag()
      Returns the physical keyboard BCP-47 language tag. | 
| 
        
        
        
        
        
        String | 
      getPhysicalKeyboardHintLayoutType()
      Returns the physical keyboard layout type string. | 
| 
        
        
        
        
        
        int | 
      hashCode()
      Returns a hash code value for the object. | 
| 
        
        
        
        
        
        boolean | 
      isAsciiCapable()
       | 
| 
        
        
        
        
        
        boolean | 
      isAuxiliary()
       | 
| 
        
        
        
        
        
        boolean | 
      overridesImplicitlyEnabledSubtype()
       | 
| 
        
        
        
        
        
        void | 
      writeToParcel(Parcel dest, int parcelableFlags)
      Flatten this object in to a Parcel. | 
| Inherited methods | |
|---|---|
XML attributes
android:icon
The icon of the subtype.
May be a reference to another resource, in the form
 "@[+][package:]type/name" or a theme
 attribute in the form
 "?[package:]type/name".
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.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
android:imeSubtypeLocale
The locale of the subtype. This string should be a locale (for example en_US and 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.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
android:imeSubtypeMode
The mode of the subtype. This string can be a mode (for example, voice and keyboard)
 and this string will be passed to the IME when the framework calls the IME with the
 subtype.  InputMethodSubtype.getLocale() returns the
 value specified in this attribute.
 
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
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.
 
Note: In order to avoid some known system issues on
 Build.VERSION_CODES.P and prior OSes, you may want to include
 "AsciiCapable" in
 InputMethod_Subtype_imeSubtypeExtraValue when you specify
 true to this attribute.
 
May be a boolean value, such as "true" or
 "false".
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.
May be a boolean value, such as "true" or
 "false".
android:label
The name of the subtype.
May be a reference to another resource, in the form
 "@[+][package:]type/name" or 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;
android:languageTag
The BCP-47 Language Tag of the subtype.  This replaces
 InputMethod_Subtype_imeSubtypeLocale.
 
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
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.
May be a boolean value, such as "true" or
 "false".
android:physicalKeyboardHintLanguageTag
The BCP-47 Language Tag of the preferred physical keyboard of the subtype. If it's not
 specified, InputMethod_Subtype_languageTag will be used.
 See also
 InputMethodSubtype.getPhysicalKeyboardHintLanguageTag().
 
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
Related methods:
android:physicalKeyboardHintLayoutType
The layout type of the preferred physical keyboard of the subtype.
 It matches the layout type string in the keyboard layout definition. See also
 InputMethodSubtype.getPhysicalKeyboardHintLayoutType().
 
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
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.
May be an integer value, such as "100".
Fields
Public constructors
InputMethodSubtype
public InputMethodSubtype (int nameId, 
                int iconId, 
                String locale, 
                String mode, 
                String extraValue, 
                boolean isAuxiliary, 
                boolean overridesImplicitlyEnabledSubtype)
      This constructor is deprecated.
    use InputMethodSubtypeBuilder instead.
 Arguments for this constructor have the same meanings as
 InputMethodSubtype.InputMethodSubtype(int, int, String, String, String, boolean,
 boolean, int) except "id".
  
Constructor with no subtype ID specified.
| Parameters | |
|---|---|
| nameId | int | 
| iconId | int | 
| locale | String | 
| mode | String | 
| extraValue | String | 
| isAuxiliary | boolean | 
| overridesImplicitlyEnabledSubtype | boolean | 
InputMethodSubtype
public InputMethodSubtype (int nameId, 
                int iconId, 
                String locale, 
                String mode, 
                String extraValue, 
                boolean isAuxiliary, 
                boolean overridesImplicitlyEnabledSubtype, 
                int id)
      This constructor is deprecated.
    use InputMethodSubtypeBuilder instead.
 "isAsciiCapable" is "false" in this constructor.
  
Constructor.
| Parameters | |
|---|---|
| nameId | int: 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 togetDisplayName(Context, String, ApplicationInfo)for details. | 
| iconId | int: Resource ID of the subtype icon drawable. | 
| locale | String: The locale supported by the subtype | 
| mode | String: The mode supported by the subtype | 
| extraValue | String: 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; seecontainsExtraValueKey(String)andgetExtraValueOf(String). | 
| isAuxiliary | boolean: 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 byInputMethodManager.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 | boolean: 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 | int: 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, isAsciiCapable}) will be used instead. | 
Public methods
containsExtraValueKey
public boolean containsExtraValueKey (String key)
The string of ExtraValue in subtype should be defined as follows: example: key0,key1=value1,key2,key3,key4=value4
| Parameters | |
|---|---|
| key | String: The key of extra value | 
| Returns | |
|---|---|
| boolean | The subtype contains specified the extra value | 
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 0orCONTENTS_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
     xandy,x.equals(y)should returntrueif and only ify.equals(x)returnstrue.
- It is transitive: for any non-null reference values
     x,y, andz, ifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue.
- It is consistent: for any non-null reference values
     xandy, multiple invocations ofx.equals(y)consistently returntrueor consistently returnfalse, provided no information used inequalscomparisons 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 benull. | 
| Returns | |
|---|---|
| boolean | trueif this object is the same as the obj
          argument;falseotherwise. | 
getDisplayName
public CharSequence getDisplayName (Context context, String packageName, ApplicationInfo appInfo)
Returns a display name for this subtype.
If subtypeNameResId is specified (!= 0) text generated from that resource will
 be returned. The localized string resource of the label should be capitalized for inclusion
 in UI lists. The string resource may contain at most one %s. If present, the
 %s will be replaced with the display name of the subtype locale in the user's locale.
 
If subtypeNameResId is not specified (== 0) the framework returns the display name
 of the subtype locale, as capitalized for use in UI lists, in the user's locale.
| Parameters | |
|---|---|
| context | Context:Contextwill be used for gettingLocaleandPackageManager. | 
| packageName | String: The package name of the input method. | 
| appInfo | ApplicationInfo: TheApplicationInfoof the input method. | 
| Returns | |
|---|---|
| CharSequence | a display name for this subtype.
 This value cannot be null. | 
getExtraValue
public String getExtraValue ()
| Returns | |
|---|---|
| String | The extra value of the subtype. | 
getExtraValueOf
public String getExtraValueOf (String key)
The string of ExtraValue in subtype should be defined as follows: example: key0,key1=value1,key2,key3,key4=value4
| Parameters | |
|---|---|
| key | String: The key of extra value | 
| Returns | |
|---|---|
| String | The value of the specified key | 
getIconResId
public int getIconResId ()
| Returns | |
|---|---|
| int | Resource ID of the subtype icon drawable. | 
getLanguageTag
public String getLanguageTag ()
| Returns | |
|---|---|
| String | the BCP-47 Language Tag of the subtype.  Returns an empty string when no Language Tag
 is specified.
 This value cannot be null. | 
See also:
getLayoutDisplayName
public CharSequence getLayoutDisplayName (Context context, ApplicationInfo imeAppInfo)
Returns the layout display name.
If layoutLabelResource is non-zero (specified through
 setLayoutLabelResource), the
 text generated from that resource will be returned. The localized string resource of the
 label should be capitalized for inclusion in UI lists.
 
If layoutLabelResource is zero, the framework returns the non-localized
 layout label, if specified through
 setLayoutLabelNonLocalized.
| Parameters | |
|---|---|
| context | Context: The context used for getting thePackageManager.
 This value cannot benull. | 
| imeAppInfo | ApplicationInfo: TheApplicationInfoof the input method.
 This value cannot benull. | 
| Returns | |
|---|---|
| CharSequence | the layout display name.
 This value cannot be null. | 
getLayoutLabelNonLocalized
public CharSequence getLayoutLabelNonLocalized ()
Returns the non-localized layout label.
| Returns | |
|---|---|
| CharSequence | This value cannot be null. | 
getLayoutLabelResource
public int getLayoutLabelResource ()
Returns the layout label string resource identifier.
| Returns | |
|---|---|
| int | |
getLocale
public String getLocale ()
      This method was deprecated
      in API level 24.
    Use getLanguageTag() instead.
  
| Returns | |
|---|---|
| String | The locale of the subtype. This method returns the "locale" string parameter passed
 to the constructor.
 This value cannot be null. | 
getNameOverride
public CharSequence getNameOverride ()
| Returns | |
|---|---|
| CharSequence | The subtype's untranslatable name string.
 This value cannot be null. | 
getNameResId
public int getNameResId ()
| Returns | |
|---|---|
| int | Resource ID of the subtype name string. | 
getPhysicalKeyboardHintLanguageTag
public ULocale getPhysicalKeyboardHintLanguageTag ()
Returns the physical keyboard BCP-47 language tag.
Related XML Attributes:
| Returns | |
|---|---|
| ULocale | This value may be null. | 
getPhysicalKeyboardHintLayoutType
public String getPhysicalKeyboardHintLayoutType ()
Returns the physical keyboard layout type string.
Related XML Attributes:
| Returns | |
|---|---|
| String | This value cannot be null. | 
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 hashCodemethod must consistently return the same integer, provided no information used inequalscomparisons 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 equalsmethod, then calling thehashCodemethod 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 equalsmethod, then calling thehashCodemethod 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. | 
isAsciiCapable
public boolean isAsciiCapable ()
| Returns | |
|---|---|
| boolean | 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. | 
isAuxiliary
public boolean isAuxiliary ()
| Returns | |
|---|---|
| boolean | 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 InputMethodManager.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
public boolean overridesImplicitlyEnabledSubtype ()
| Returns | |
|---|---|
| boolean | 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. | 
writeToParcel
public void writeToParcel (Parcel dest, int parcelableFlags)
Flatten this object in to a Parcel.
| Parameters | |
|---|---|
| dest | Parcel: The Parcel in which the object should be written.
 This value cannot benull. | 
| parcelableFlags | int: Additional flags about how the object should be written.
 May be 0 orParcelable.PARCELABLE_WRITE_RETURN_VALUE.
 Value is either0or a combination ofParcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES | 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-03-13 UTC.
