InputMethodInfo


public final class InputMethodInfo
extends Object implements Parcelable

java.lang.Object
   ↳ android.view.inputmethod.InputMethodInfo


This class is used to specify meta information of an input method.

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

See also:

Summary

XML attributes

android:configChanges Specify one or more configuration changes that the IME will handle itself. 
android:isDefault Set to true in all of the configurations for which this input method should be considered an option as the default. 
android:settingsActivity Component name of an activity that allows the user to modify the settings for this service. 
android:showInInputMethodPicker Specifies whether the IME wants to be shown in the Input Method picker. 
android:stylusHandwritingSettingsActivity Class name of an activity that allows the user to modify the stylus handwriting settings for this service

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

android:supportsConnectionlessStylusHandwriting Specifies whether the IME supports connectionless stylus handwriting sessions. 
android:supportsInlineSuggestions Specifies whether the IME supports showing inline suggestions. 
android:supportsInlineSuggestionsWithTouchExploration Specifies whether the IME supports showing inline suggestions when touch exploration is enabled. 
android:supportsStylusHandwriting Specifies whether the IME supports Handwriting using stylus. 
android:supportsSwitchingToNextInputMethod Set to true if this input method supports ways to switch to a next input method (for example, a globe key.). 
android:suppressesSpellChecker Specifies whether the IME suppresses system spell checker. 

Constants

String ACTION_STYLUS_HANDWRITING_SETTINGS

Intent action for IME that supports stylus handwriting.

Inherited constants

Fields

public static final Creator<InputMethodInfo> CREATOR

Used to make this class parcelable.

Public constructors

InputMethodInfo(Context context, ResolveInfo service)

Constructor.

InputMethodInfo(String packageName, String className, CharSequence label, String settingsActivity)

Temporary API for creating a built-in input method for test.

Public methods

Intent createStylusHandwritingSettingsActivityIntent()

Returns Intent for stylus handwriting settings activity with Intent action ACTION_STYLUS_HANDWRITING_SETTINGS if IME supports stylus handwriting, else null if there are no associated settings for stylus handwriting / handwriting is not supported or if R.styleable.InputMethod_stylusHandwritingSettingsActivity is not defined.

int describeContents()

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

void dump(Printer pw, String prefix)
boolean equals(Object o)

Used to test whether the given parameter object is an InputMethodInfo and its Id is the same to this one.

ComponentName getComponent()

Return the component of the service that implements this input method.

int getConfigChanges()

Returns the bit mask of kinds of configuration changes that this IME can handle itself (without being restarted by the system).

String getId()
int getIsDefaultResourceId()

Return the resource identifier of a resource inside of this input method's .apk that determines whether it should be considered a default input method for the system.

String getPackageName()

Return the .apk package that implements this input method.

ServiceInfo getServiceInfo()

Return the raw information about the Service implementing this input method.

String getServiceName()

Return the class name of the service component that implements this input method.

String getSettingsActivity()

Return the class name of an activity that provides a settings UI for the input method.

InputMethodSubtype getSubtypeAt(int index)

Return the Input Method's subtype at the specified index.

int getSubtypeCount()

Return the count of the subtypes of Input Method.

int hashCode()

Returns a hash code value for the object.

Drawable loadIcon(PackageManager pm)

Load the user-displayed icon for this input method.

CharSequence loadLabel(PackageManager pm)

Load the user-displayed label for this input method.

boolean shouldShowInInputMethodPicker()

Returns true if this input method should be shown in menus for selecting an Input Method, such as the system Input Method Picker.

boolean supportsConnectionlessStylusHandwriting()

Returns whether the IME supports connectionless stylus handwriting sessions.

boolean supportsStylusHandwriting()

Returns if IME supports handwriting using stylus input.

boolean suppressesSpellChecker()

Return true if this input method suppresses spell checker.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel dest, int flags)

Used to package this object into a Parcel.

Inherited methods

XML attributes

android:configChanges

Specify one or more configuration changes that the IME will handle itself. If not specified, the IME will be restarted if any of these configuration changes happen in the system. Otherwise, the IME will remain running and its InputMethodService.onConfigurationChanged(Configuration) method is called with the new configuration.

Note that all of these configuration changes can impact the resource values seen by the application, so you will generally need to re-retrieve all resources (including view layouts, drawables, etc) to correctly handle any configuration change.

Must be one or more (separated by '|') of the following constant values.

ConstantValueDescription
colorMode4000The color mode of the screen has changed (color gamut or dynamic range).
density1000The display density has changed. This might be caused by the user specifying a different display scale, or it might be caused by a different display being activated.
fontScale40000000The font scaling factor has changed, that is the user has selected a new global font size.
fontWeightAdjustment10000000The font weight adjustment value has changed. Used to reflect the user increasing font weight.
grammaticalGender8000The grammatical gender has changed, for example the user set the grammatical gender from the UI.
keyboard10The keyboard type has changed, for example the user has plugged in an external keyboard.
keyboardHidden20The keyboard or navigation accessibility has changed, for example the user has slid the keyboard out to expose it. Note that despite its name, this applied to any accessibility: keyboard or navigation.
layoutDirection2000The layout direction has changed. For example going from LTR to RTL.
locale4The locale has changed, that is the user has selected a new language that text should be displayed in.
mcc1The IMSI MCC has changed, that is a SIM has been detected and updated the Mobile Country Code. By default from Android O, we don't recreate the activity even the app doesn't specify mcc in configChanges. If the app wants to recreate the activity, specify mcc in recreateOnConfigChanges.
mnc2The IMSI MNC has changed, that is a SIM has been detected and updated the Mobile Network Code. By default from Android O, we don't recreate the activity even the app doesn't specify mnc in configChanges. If the app wants to recreate the acvitity, specify mnc in recreateOnConfigChanges.
navigation40The navigation type has changed. Should never normally happen.
orientation80The screen orientation has changed, that is the user has rotated the device.
screenLayout100The screen layout has changed. This might be caused by a different display being activated.
screenSize400The current available screen size has changed. If applications don't target at least Build.VERSION_CODES.HONEYCOMB_MR2 then the activity will always handle this itself (the change will not result in a restart). This represents a change in the currently available size, so will change when the user switches between landscape and portrait.
smallestScreenSize800The physical screen size has changed. If applications don't target at least Build.VERSION_CODES.HONEYCOMB_MR2 then the activity will always handle this itself (the change will not result in a restart). This represents a change in size regardless of orientation, so will only change when the actual physical screen size has changed such as switching to an external display.
touchscreen8The touchscreen has changed. Should never normally happen.
uiMode200The global user interface mode has changed. For example, going in or out of car mode, night mode changing, etc.

Related methods:

android:isDefault

Set to true in all of the configurations for which this input method should be considered an option as the default.

May be a boolean value, such as "true" or "false".

android:settingsActivity

Component name of an activity that allows the user to modify the settings for this service.

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

android:showInInputMethodPicker

Specifies whether the IME wants to be shown in the Input Method picker. Defaults to true. Set this to false if the IME is intended to be accessed programmatically.

Note: This functions as a hint to the system, which may choose to ignore this preference in certain situations or in future releases.

May be a boolean value, such as "true" or "false".

android:stylusHandwritingSettingsActivity

Class name of an activity that allows the user to modify the stylus handwriting settings for this service

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

Related methods:

android:supportsConnectionlessStylusHandwriting

Specifies whether the IME supports connectionless stylus handwriting sessions. A connectionless session differs from a regular session in that the IME does not use an input connection to communicate with a text editor. Instead, the IME directly returns recognised handwritten text via an InputMethodService handwriting lifecycle API.

If the IME supports connectionless sessions, apps or framework may start a connectionless session when a stylus motion event sequence begins. InputMethodService.onStartConnectionlessStylusHandwriting(int, CursorAnchorInfo) is called. If the IME is ready for stylus input, it should return {code true} to start the basic mode session. As in the regular session, the IME will receive stylus motion events to the stylus handwriting window and should render ink to a view in this window. When the user has stopped handwriting, the IME should end the session and deliver the result by calling InputMethodService.finishConnectionlessStylusHandwriting(CharSequence). The default value is {code false}. If {code true}, R.attr.supportsStylusHandwriting should also be {code true}.

May be a boolean value, such as "true" or "false".

Related methods:

android:supportsInlineSuggestions

Specifies whether the IME supports showing inline suggestions.

May be a boolean value, such as "true" or "false".

android:supportsInlineSuggestionsWithTouchExploration

Specifies whether the IME supports showing inline suggestions when touch exploration is enabled. This does nothing if supportsInlineSuggestions is false. The default value is false and most IMEs should not set this to true since the older menu-style Autofill works better with touch exploration. This attribute should be set to true in special situations, such as if this is an accessibility-focused IME which blocks user interaction with the app window while the IME is displayed.

May be a boolean value, such as "true" or "false".

android:supportsStylusHandwriting

Specifies whether the IME supports Handwriting using stylus. Defaults to false. When IME implements support for stylus handwriting, on every ACTION_DOWN with stylus on an editor, InputMethodService.onStartStylusHandwriting() is called. If IME is ready for stylus input, it must return true for Handwriting sessions to start. IME should attach it's View that renders Ink on screen to stylus handwriting inking window InputMethodService.getStylusHandwritingWindow(). IME will then receive Stylus MotionEvent(s) on DecorView i.e. the Inking view View.onTouchEvent(MotionEvent) attached by IME to Ink window. Handwriting mode can be finished by calling InputMethodService.finishStylusHandwriting() or will be finished by framework on next InputMethodService.onFinishInput().

May be a boolean value, such as "true" or "false".

Related methods:

android:supportsSwitchingToNextInputMethod

Set to true if this input method supports ways to switch to a next input method (for example, a globe key.). When this is true and InputMethodManager#shouldOfferSwitchingToNextInputMethod() returns true, the IME has to offer ways to invoke InputMethodManager#switchToNextInputMethod() accordingly.

Note that the system determines the most appropriate next input method and subtype in order to provide the consistent user experience in switching between IMEs and subtypes.

May be a boolean value, such as "true" or "false".

android:suppressesSpellChecker

Specifies whether the IME suppresses system spell checker. The default value is false. If an IME sets this attribute to true, the system spell checker will be disabled while the IME has an active input session.

May be a boolean value, such as "true" or "false".

Constants

ACTION_STYLUS_HANDWRITING_SETTINGS

Added in API level 34
public static final String ACTION_STYLUS_HANDWRITING_SETTINGS

Intent action for IME that supports stylus handwriting.

Constant Value: "android.view.inputmethod.action.STYLUS_HANDWRITING_SETTINGS"

Fields

CREATOR

Added in API level 3
public static final Creator<InputMethodInfo> CREATOR

Used to make this class parcelable.

Public constructors

InputMethodInfo

Added in API level 3
public InputMethodInfo (Context context, 
                ResolveInfo service)

Constructor.

Parameters
context Context: The Context in which we are parsing the input method.

service ResolveInfo: The ResolveInfo returned from the package manager about this input method's component.

Throws
IOException
XmlPullParserException

InputMethodInfo

Added in API level 3
public InputMethodInfo (String packageName, 
                String className, 
                CharSequence label, 
                String settingsActivity)

Temporary API for creating a built-in input method for test.

Parameters
packageName String

className String

label CharSequence

settingsActivity String

Public methods

createStylusHandwritingSettingsActivityIntent

Added in API level 34
public Intent createStylusHandwritingSettingsActivityIntent ()

Returns Intent for stylus handwriting settings activity with Intent action ACTION_STYLUS_HANDWRITING_SETTINGS if IME supports stylus handwriting, else null if there are no associated settings for stylus handwriting / handwriting is not supported or if R.styleable.InputMethod_stylusHandwritingSettingsActivity is not defined.

To launch stylus settings, use this method to get the Intent to launch the stylus handwriting settings activity.

e.g.

startActivity(createStylusHandwritingSettingsActivityIntent());
 

Related XML Attributes:

Returns
Intent

describeContents

Added in API level 3
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

dump

Added in API level 3
public void dump (Printer pw, 
                String prefix)

Parameters
pw Printer

prefix String

equals

Added in API level 3
public boolean equals (Object o)

Used to test whether the given parameter object is an InputMethodInfo and its Id is the same to this one.

Parameters
o Object: This value may be null.

Returns
boolean true if the given parameter object is an InputMethodInfo and its Id is the same to this one.

getComponent

Added in API level 3
public ComponentName getComponent ()

Return the component of the service that implements this input method.

Returns
ComponentName

getConfigChanges

Added in API level 31
public int getConfigChanges ()

Returns the bit mask of kinds of configuration changes that this IME can handle itself (without being restarted by the system).

Related XML Attributes:

Returns
int Value is either 0 or a combination of ActivityInfo.CONFIG_MCC, ActivityInfo.CONFIG_MNC, ActivityInfo.CONFIG_LOCALE, ActivityInfo.CONFIG_TOUCHSCREEN, ActivityInfo.CONFIG_KEYBOARD, ActivityInfo.CONFIG_KEYBOARD_HIDDEN, ActivityInfo.CONFIG_NAVIGATION, ActivityInfo.CONFIG_ORIENTATION, ActivityInfo.CONFIG_SCREEN_LAYOUT, ActivityInfo.CONFIG_UI_MODE, ActivityInfo.CONFIG_SCREEN_SIZE, ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE, ActivityInfo.CONFIG_DENSITY, ActivityInfo.CONFIG_LAYOUT_DIRECTION, ActivityInfo.CONFIG_COLOR_MODE, ActivityInfo.CONFIG_FONT_SCALE, and ActivityInfo.CONFIG_GRAMMATICAL_GENDER

getId

Added in API level 3
public String getId ()

Returns
String a unique ID for this input method, which is guaranteed to be the same as the result of getComponent().flattenToShortString().

getIsDefaultResourceId

Added in API level 3
public int getIsDefaultResourceId ()

Return the resource identifier of a resource inside of this input method's .apk that determines whether it should be considered a default input method for the system.

Returns
int

getPackageName

Added in API level 3
public String getPackageName ()

Return the .apk package that implements this input method.

Returns
String

getServiceInfo

Added in API level 3
public ServiceInfo getServiceInfo ()

Return the raw information about the Service implementing this input method. Do not modify the returned object.

Returns
ServiceInfo

getServiceName

Added in API level 3
public String getServiceName ()

Return the class name of the service component that implements this input method.

Returns
String

getSettingsActivity

Added in API level 3
public String getSettingsActivity ()

Return the class name of an activity that provides a settings UI for the input method. You can launch this activity be starting it with an Intent whose action is MAIN and with an explicit ComponentName composed of getPackageName() and the class name returned here.

A null will be returned if there is no settings activity associated with the input method.

Returns
String

getSubtypeAt

Added in API level 11
public InputMethodSubtype getSubtypeAt (int index)

Return the Input Method's subtype at the specified index.

Parameters
index int: the index of the subtype to return.

Returns
InputMethodSubtype

getSubtypeCount

Added in API level 11
public int getSubtypeCount ()

Return the count of the subtypes of Input Method.

Returns
int

hashCode

Added in API level 3
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 in equals 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 the hashCode 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 the hashCode 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.

loadIcon

Added in API level 3
public Drawable loadIcon (PackageManager pm)

Load the user-displayed icon for this input method.

Parameters
pm PackageManager: Supply a PackageManager used to load the input method's resources.

Returns
Drawable

loadLabel

Added in API level 3
public CharSequence loadLabel (PackageManager pm)

Load the user-displayed label for this input method.

Parameters
pm PackageManager: Supply a PackageManager used to load the input method's resources.

Returns
CharSequence

shouldShowInInputMethodPicker

Added in API level 31
public boolean shouldShowInInputMethodPicker ()

Returns true if this input method should be shown in menus for selecting an Input Method, such as the system Input Method Picker. This is false if the IME is intended to be accessed programmatically.

Returns
boolean

supportsConnectionlessStylusHandwriting

Added in API level 35
public boolean supportsConnectionlessStylusHandwriting ()

Returns whether the IME supports connectionless stylus handwriting sessions.

Related XML Attributes:

Returns
boolean

supportsStylusHandwriting

Added in API level 33
public boolean supportsStylusHandwriting ()

Returns if IME supports handwriting using stylus input.

Related XML Attributes:

Returns
boolean

suppressesSpellChecker

Added in API level 31
public boolean suppressesSpellChecker ()

Return true if this input method suppresses spell checker.

Returns
boolean

toString

Added in API level 3
public String toString ()

Returns a string representation of the object.

Returns
String a string representation of the object.

writeToParcel

Added in API level 3
public void writeToParcel (Parcel dest, 
                int flags)

Used to package this object into a Parcel.

Parameters
dest Parcel: The Parcel to be written.

flags int: The flags used for parceling.