EditorInfoCompat

public final class EditorInfoCompat
extends Object

java.lang.Object
   ↳ androidx.core.view.inputmethod.EditorInfoCompat


Helper for accessing features in EditorInfo in a backwards compatible fashion.

Summary

Constants

int IME_FLAG_FORCE_ASCII

Flag of EditorInfo.imeOptions: used to request an IME that is capable of inputting ASCII characters.

int IME_FLAG_NO_PERSONALIZED_LEARNING

Flag of EditorInfo.imeOptions: used to request that the IME does not update any personalized data such as typing history and personalized language model based on what the user typed on this text editing object.

Public constructors

EditorInfoCompat()

This constructor is deprecated. This type should not be instantiated as it contains only static methods.

Public methods

static String[] getContentMimeTypes(EditorInfo editorInfo)

Gets MIME types that can be accepted by the target editor if the IME calls InputConnectionCompat.commitContent(InputConnection, EditorInfo, InputContentInfoCompat, int, Bundle)

static void setContentMimeTypes(EditorInfo editorInfo, String[] contentMimeTypes)

Sets MIME types that can be accepted by the target editor if the IME calls InputConnectionCompat.commitContent(InputConnection, EditorInfo, InputContentInfoCompat, int, Bundle).

Inherited methods

Constants

IME_FLAG_FORCE_ASCII

public static final int IME_FLAG_FORCE_ASCII

Flag of EditorInfo.imeOptions: used to request an IME that is capable of inputting ASCII characters.

The intention of this flag is to ensure that the user can type Roman alphabet characters in a TextView. It is typically used for an account ID or password input.

In many cases, IMEs are already able to input ASCII even without being told so (such IMEs already respect this flag in a sense), but there are cases when this is not the default. For instance, users of languages using a different script like Arabic, Greek, Hebrew or Russian typically have a keyboard that can't input ASCII characters by default.

Applications need to be aware that the flag is not a guarantee, and some IMEs may not respect it. However, it is strongly recommended for IME authors to respect this flag especially when their IME could end up with a state where only languages using non-ASCII are enabled.

Constant Value: -2147483648 (0x80000000)

IME_FLAG_NO_PERSONALIZED_LEARNING

public static final int IME_FLAG_NO_PERSONALIZED_LEARNING

Flag of EditorInfo.imeOptions: used to request that the IME does not update any personalized data such as typing history and personalized language model based on what the user typed on this text editing object. Typical use cases are:

  • When the application is in a special mode, where user's activities are expected to be not recorded in the application's history. Some web browsers and chat applications may have this kind of modes.
  • When storing typing history does not make much sense. Specifying this flag in typing games may help to avoid typing history from being filled up with words that the user is less likely to type in their daily life. Another example is that when the application already knows that the expected input is not a valid word (e.g. a promotion code that is not a valid word in any natural language).

Applications need to be aware that the flag is not a guarantee, and some IMEs may not respect it.

Constant Value: 16777216 (0x01000000)

Public constructors

EditorInfoCompat

public EditorInfoCompat ()

This constructor is deprecated.
This type should not be instantiated as it contains only static methods.

Public methods

getContentMimeTypes

public static String[] getContentMimeTypes (EditorInfo editorInfo)

Gets MIME types that can be accepted by the target editor if the IME calls InputConnectionCompat.commitContent(InputConnection, EditorInfo, InputContentInfoCompat, int, Bundle)

Parameters
editorInfo EditorInfo: the editor from which we get the MIME types

Returns
String[] an array of MIME types. An empty array means that InputConnectionCompat.commitContent(InputConnection, EditorInfo, InputContentInfoCompat, int, Bundle) is not supported on this editor

setContentMimeTypes

public static void setContentMimeTypes (EditorInfo editorInfo, 
                String[] contentMimeTypes)

Sets MIME types that can be accepted by the target editor if the IME calls InputConnectionCompat.commitContent(InputConnection, EditorInfo, InputContentInfoCompat, int, Bundle).

Parameters
editorInfo EditorInfo: the editor with which we associate supported MIME types

contentMimeTypes String: an array of MIME types. null and an empty array means that InputConnectionCompat.commitContent(InputConnection, EditorInfo, InputContentInfoCompat, int, Bundle) is not supported on this Editor