# EmojiCompat

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-emoji:28.0.0-alpha1  
Summary:[Nested Classes](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#nestedclasses)\|[Constants](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#constants)\|[Methods](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#)  

# EmojiCompat

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
EmojiCompat
`  
`

extends Object


``


`

|---|----------------------------------------|
| java.lang.Object                          ||
| ↳ | android.support.text.emoji.EmojiCompat |

<br />

*** ** * ** ***

Main class to keep Android devices up to date with the newest emojis by adding[EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan)s to a given[CharSequence](https://developer.android.com/reference/java/lang/CharSequence). It is a singleton class that can be configured using a[EmojiCompat.Config](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.Config)instance.

<br />

EmojiCompat has to be initialized using[init(EmojiCompat.Config)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#init(android.support.text.emoji.EmojiCompat.Config))function before it can process a[CharSequence](https://developer.android.com/reference/java/lang/CharSequence).  

    EmojiCompat.init(/* a config instance */);

<br />

It is suggested to make the initialization as early as possible in your app. Please check[EmojiCompat.Config](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.Config)for more configuration parameters.

<br />

During initialization information about emojis is loaded on a background thread. Before the EmojiCompat instance is initialized, calls to functions such as[process(CharSequence)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#process(java.lang.CharSequence))will throw an exception. You can use the[EmojiCompat.InitCallback](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.InitCallback)class to be informed about the state of initialization.

<br />

After initialization the[get()](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#get())function can be used to get the configured instance and the[process(CharSequence)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#process(java.lang.CharSequence))function can be used to update a CharSequence with emoji EmojiSpans.

<br />

    CharSequence processedSequence = EmojiCompat.get().process("some string")

`
`<br />

`


`

## Summary

`


``
`

|                                                                                                           ### Nested classes                                                                                                           ||
|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class`     | [EmojiCompat.Config](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.Config) Configuration class for EmojiCompat.                                                                         |
| ` class`     | [EmojiCompat.InitCallback](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.InitCallback) Listener class for the initialization of the EmojiCompat.                                        |
| ` interface` | [EmojiCompat.MetadataRepoLoader](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.MetadataRepoLoader) Interface to load emoji metadata.                                                    |
| ` class`     | [EmojiCompat.MetadataRepoLoaderCallback](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.MetadataRepoLoaderCallback) Callback to inform EmojiCompat about the state of the metadata load. |

|                                                                                                                                                                                                                ### Constants                                                                                                                                                                                                                 ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `String` | [EDITOR_INFO_METAVERSION_KEY](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#EDITOR_INFO_METAVERSION_KEY) Key in [extras](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#extras) that represents the emoji metadata version used by the widget.                                                                                                                  |
| `String` | [EDITOR_INFO_REPLACE_ALL_KEY](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#EDITOR_INFO_REPLACE_ALL_KEY) Key in [extras](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#extras) that represents [setReplaceAll(boolean)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.Config#setReplaceAll(boolean)) configuration parameter. |
| `int`    | [LOAD_STATE_FAILED](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#LOAD_STATE_FAILED) An unrecoverable error occurred during initialization of EmojiCompat.                                                                                                                                                                                                                                        |
| `int`    | [LOAD_STATE_LOADING](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#LOAD_STATE_LOADING) EmojiCompat is initializing.                                                                                                                                                                                                                                                                               |
| `int`    | [LOAD_STATE_SUCCEEDED](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#LOAD_STATE_SUCCEEDED) EmojiCompat successfully initialized.                                                                                                                                                                                                                                                                  |
| `int`    | [REPLACE_STRATEGY_ALL](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#REPLACE_STRATEGY_ALL) Replace strategy to add [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan)s for all emoji that were found.                                                                                                                                                      |
| `int`    | [REPLACE_STRATEGY_DEFAULT](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#REPLACE_STRATEGY_DEFAULT) Replace strategy that uses the value given in [EmojiCompat.Config](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.Config).                                                                                                                                     |
| `int`    | [REPLACE_STRATEGY_NON_EXISTENT](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#REPLACE_STRATEGY_NON_EXISTENT) Replace strategy to add [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan)s only for emoji that do not exist in the system.                                                                                                                   |

`


``
`

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ||
|---------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[EmojiCompat](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat) | ` `[get](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#get())`() ` Return singleton EmojiCompat instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` String`                                                                                               | ` `[getAssetSignature](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#getAssetSignature())`() ` Returns signature for the currently loaded emoji assets.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` int`                                                                                                  | ` `[getLoadState](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#getLoadState())`() ` Returns loading state of the EmojiCompat instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` static boolean`                                                                                       | ` `[handleDeleteSurroundingText](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#handleDeleteSurroundingText(android.view.inputmethod.InputConnection, android.text.Editable, int, int, boolean))`(`[InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html)` inputConnection, `[Editable](https://developer.android.com/reference/android/text/Editable.html)` editable, int beforeLength, int afterLength, boolean inCodePoints) ` Handles deleteSurroundingText commands from [InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html) and tries to delete an [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan) from an [Editable](https://developer.android.com/reference/android/text/Editable.html).                                                                          |
| ` static boolean`                                                                                       | ` `[handleOnKeyDown](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#handleOnKeyDown(android.text.Editable, int, android.view.KeyEvent))`(`[Editable](https://developer.android.com/reference/android/text/Editable.html)` editable, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)` event) ` Handles onKeyDown commands from a [KeyListener](https://developer.android.com/reference/android/text/method/KeyListener.html) and if `keyCode` is one of [KEYCODE_DEL](https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_DEL) or [KEYCODE_FORWARD_DEL](https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_FORWARD_DEL) it tries to delete an [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan) from an [Editable](https://developer.android.com/reference/android/text/Editable.html). |
| ` boolean`                                                                                              | ` `[hasEmojiGlyph](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#hasEmojiGlyph(java.lang.CharSequence))`(CharSequence sequence) ` Returns `true` if EmojiCompat is capable of rendering an emoji.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` boolean`                                                                                              | ` `[hasEmojiGlyph](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#hasEmojiGlyph(java.lang.CharSequence, int))`(CharSequence sequence, int metadataVersion) ` Returns `true` if EmojiCompat is capable of rendering an emoji at the given metadata version.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` static `[EmojiCompat](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat) | ` `[init](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#init(android.support.text.emoji.EmojiCompat.Config))`(`[EmojiCompat.Config](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.Config)` config) ` Initialize the singleton instance with a configuration.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` CharSequence`                                                                                         | ` `[process](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#process(java.lang.CharSequence))`(CharSequence charSequence) ` Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` CharSequence`                                                                                         | ` `[process](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#process(java.lang.CharSequence, int, int, int, int))`(CharSequence charSequence, int start, int end, int maxEmojiCount, int replaceStrategy) ` Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` CharSequence`                                                                                         | ` `[process](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#process(java.lang.CharSequence, int, int, int))`(CharSequence charSequence, int start, int end, int maxEmojiCount) ` Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` CharSequence`                                                                                         | ` `[process](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#process(java.lang.CharSequence, int, int))`(CharSequence charSequence, int start, int end) ` Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` void`                                                                                                 | ` `[registerInitCallback](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#registerInitCallback(android.support.text.emoji.EmojiCompat.InitCallback))`(`[EmojiCompat.InitCallback](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.InitCallback)` initCallback) ` Registers an initialization callback.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` void`                                                                                                 | ` `[unregisterInitCallback](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#unregisterInitCallback(android.support.text.emoji.EmojiCompat.InitCallback))`(`[EmojiCompat.InitCallback](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.InitCallback)` initCallback) ` Unregisters a callback that was added before.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

`


``
`

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#)From class ` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

`


``


``


``


``
`

## Constants

`


``

`  

### EDITOR_INFO_METAVERSION_KEY

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
String EDITOR_INFO_METAVERSION_KEY
```

Key in [extras](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#extras) that represents the emoji metadata version used by the
widget. The existence of the value means that the widget is using EmojiCompat.

<br />

If exists, the value for the key is an `int` and can be used to query EmojiCompat to see whether the widget has the ability to display a certain emoji using [hasEmojiGlyph(CharSequence, int)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#hasEmojiGlyph(java.lang.CharSequence, int)).

<br />

<br />

Constant Value:

"android.support.text.emoji.emojiCompat_metadataVersion"


`


``

`  

### EDITOR_INFO_REPLACE_ALL_KEY

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
String EDITOR_INFO_REPLACE_ALL_KEY
```

Key in [extras](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#extras) that represents [setReplaceAll(boolean)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.Config#setReplaceAll(boolean)) configuration parameter. The key is added only if
EmojiCompat is used by the widget. If exists, the value is a boolean.

<br />

Constant Value:

"android.support.text.emoji.emojiCompat_replaceAll"


`


``

`  

### LOAD_STATE_FAILED

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int LOAD_STATE_FAILED
```

An unrecoverable error occurred during initialization of EmojiCompat. Calls to functions
such as [process(CharSequence)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#process(java.lang.CharSequence)) will fail.

<br />

Constant Value:

2
(0x00000002)


`


``

`  

### LOAD_STATE_LOADING

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int LOAD_STATE_LOADING
```

EmojiCompat is initializing.

<br />

Constant Value:

0
(0x00000000)


`


``

`  

### LOAD_STATE_SUCCEEDED

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int LOAD_STATE_SUCCEEDED
```

EmojiCompat successfully initialized.

<br />

Constant Value:

1
(0x00000001)


`


``

`  

### REPLACE_STRATEGY_ALL

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int REPLACE_STRATEGY_ALL
```

Replace strategy to add [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan)s for all emoji that were found.

<br />

Constant Value:

1
(0x00000001)


`


``

`  

### REPLACE_STRATEGY_DEFAULT

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int REPLACE_STRATEGY_DEFAULT
```

Replace strategy that uses the value given in [EmojiCompat.Config](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.Config).

<br />

Constant Value:

0
(0x00000000)


`


``

`  

### REPLACE_STRATEGY_NON_EXISTENT

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int REPLACE_STRATEGY_NON_EXISTENT
```

Replace strategy to add [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan)s only for emoji that do not exist in the system.

<br />

Constant Value:

2
(0x00000002)


`


``


``


``
``


``
``

`

## Public methods

`


``

`  

### get

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
EmojiCompat get ()
```

Return singleton EmojiCompat instance. Should be called after
[init(EmojiCompat.Config)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#init(android.support.text.emoji.EmojiCompat.Config)) is called to initialize the singleton instance.

<br />

|                                                          Returns                                                           ||
|-----------------------------------------------------------------------------------------------|-----------------------------|
| [EmojiCompat](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat) | EmojiCompat instance <br /> |

|                                                                                                  Throws                                                                                                  ||
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `IllegalStateException` | if called before [init(EmojiCompat.Config)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#init(android.support.text.emoji.EmojiCompat.Config)) |

`


``

`  

### getAssetSignature

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
String getAssetSignature ()
```

Returns signature for the currently loaded emoji assets. The signature is a SHA that is
constructed using emoji assets. Can be used to detect if currently loaded asset is different
then previous executions. When used on devices running API 18 or below, returns empty string.

<br />

|     Returns      ||
|----------|--------|
| `String` | <br /> |

|                     Throws                      ||
|-------------------------|------------------------|
| `IllegalStateException` | if not initialized yet |

`


``

`  

### getLoadState

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int getLoadState ()
```

Returns loading state of the EmojiCompat instance. When used on devices running API 18 or
below always returns [LOAD_STATE_SUCCEEDED](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#LOAD_STATE_SUCCEEDED).

<br />

|                                                                                                                                                                                             Returns                                                                                                                                                                                              ||
|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | one of [LOAD_STATE_LOADING](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#LOAD_STATE_LOADING), [LOAD_STATE_SUCCEEDED](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#LOAD_STATE_SUCCEEDED), [LOAD_STATE_FAILED](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#LOAD_STATE_FAILED) <br /> |

`


``

`  

### handleDeleteSurroundingText

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean handleDeleteSurroundingText (InputConnection inputConnection, 
                Editable editable, 
                int beforeLength, 
                int afterLength, 
                boolean inCodePoints)
```

Handles deleteSurroundingText commands from [InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html) and tries to delete an
[EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan) from an [Editable](https://developer.android.com/reference/android/text/Editable.html). Returns `true` if an [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan) is
deleted.

<br />

If there is a selection where selection start is not equal to selection end, does not delete.

<br />

When used on devices running API 18 or below, always returns `false`.

<br />

<br />

|                                        Parameters                                         ||
|-------------------|------------------------------------------------------------------------|
| `inputConnection` | `InputConnection`: InputConnection instance <br />                     |
| `editable`        | `Editable`: TextView.Editable instance <br />                          |
| `beforeLength`    | `int`: the number of characters before the cursor to be deleted <br /> |
| `afterLength`     | `int`: the number of characters after the cursor to be deleted <br />  |
| `inCodePoints`    | `boolean`: `true` if length parameters are in codepoints <br />        |

|                                                               Returns                                                               ||
|-----------|--------------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true` if an [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan) is deleted <br /> |

`


``

`  

### handleOnKeyDown

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean handleOnKeyDown (Editable editable, 
                int keyCode, 
                KeyEvent event)
```

Handles onKeyDown commands from a [KeyListener](https://developer.android.com/reference/android/text/method/KeyListener.html) and if `keyCode` is one of
[KEYCODE_DEL](https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_DEL) or [KEYCODE_FORWARD_DEL](https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_FORWARD_DEL) it tries to delete an
[EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan) from an [Editable](https://developer.android.com/reference/android/text/Editable.html). Returns `true` if an [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan) is
deleted with the characters it covers.

<br />

If there is a selection where selection start is not equal to selection end, does not delete.

<br />

When used on devices running API 18 or below, always returns `false`.

<br />

<br />

|                                                                                                                                    Parameters                                                                                                                                    ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `editable` | `Editable`: Editable instance passed to [onKeyDown(android.view.View, Editable, int, KeyEvent)](https://developer.android.com/reference/android/text/method/KeyListener.html#onKeyDown(android.view.View, android.text.Editable, int, android.view.KeyEvent)) <br /> |
| `keyCode`  | `int`: keyCode passed to [onKeyDown(android.view.View, Editable, int, KeyEvent)](https://developer.android.com/reference/android/text/method/KeyListener.html#onKeyDown(android.view.View, android.text.Editable, int, android.view.KeyEvent)) <br />                |
| `event`    | `KeyEvent`: KeyEvent passed to [onKeyDown(android.view.View, Editable, int, KeyEvent)](https://developer.android.com/reference/android/text/method/KeyListener.html#onKeyDown(android.view.View, android.text.Editable, int, android.view.KeyEvent)) <br />          |

|                                                               Returns                                                               ||
|-----------|--------------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true` if an [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan) is deleted <br /> |

`


``

`  

### hasEmojiGlyph

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean hasEmojiGlyph (CharSequence sequence)
```

Returns `true` if EmojiCompat is capable of rendering an emoji. When used on devices
running API 18 or below, always returns `false`.

<br />

|                               Parameters                               ||
|------------|------------------------------------------------------------|
| `sequence` | `CharSequence`: CharSequence representing the emoji <br /> |

|                                     Returns                                      ||
|-----------|-----------------------------------------------------------------------|
| `boolean` | `true` if EmojiCompat can render given emoji, cannot be `null` <br /> |

|                     Throws                      ||
|-------------------------|------------------------|
| `IllegalStateException` | if not initialized yet |

`


``

`  

### hasEmojiGlyph

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean hasEmojiGlyph (CharSequence sequence, 
                int metadataVersion)
```

Returns `true` if EmojiCompat is capable of rendering an emoji at the given metadata
version. When used on devices running API 18 or below, always returns `false`.

<br />

|                                                   Parameters                                                    ||
|-------------------|----------------------------------------------------------------------------------------------|
| `sequence`        | `CharSequence`: CharSequence representing the emoji <br />                                   |
| `metadataVersion` | `int`: the metadata version to check against, should be greater than or equal to `0`, <br /> |

|                                     Returns                                      ||
|-----------|-----------------------------------------------------------------------|
| `boolean` | `true` if EmojiCompat can render given emoji, cannot be `null` <br /> |

|                     Throws                      ||
|-------------------------|------------------------|
| `IllegalStateException` | if not initialized yet |

`


``

`  

### init

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
EmojiCompat init (EmojiCompat.Config config)
```

Initialize the singleton instance with a configuration. When used on devices running API 18
or below, the singleton instance is immediately moved into [LOAD_STATE_SUCCEEDED](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#LOAD_STATE_SUCCEEDED)
state without loading any metadata.

<br />

|              Parameters               ||
|----------|-----------------------------|
| `config` | `EmojiCompat.Config` <br /> |

|                                                Returns                                                ||
|-----------------------------------------------------------------------------------------------|--------|
| [EmojiCompat](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat) | <br /> |

**See also:**

- [EmojiCompat.Config](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.Config)
`


``

`  

### process

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CharSequence process (CharSequence charSequence)
```

Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found. When
used on devices running API 18 or below, returns the given `charSequence` without
processing it.

<br />

|                                Parameters                                 ||
|----------------|-----------------------------------------------------------|
| `charSequence` | `CharSequence`: CharSequence to add the EmojiSpans <br /> |

|        Returns         ||
|----------------|--------|
| `CharSequence` | <br /> |

|                     Throws                      ||
|-------------------------|------------------------|
| `IllegalStateException` | if not initialized yet |

**See also:**

- [process(CharSequence, int, int)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#process(java.lang.CharSequence, int, int))
`


``

`  

### process

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CharSequence process (CharSequence charSequence, 
                int start, 
                int end, 
                int maxEmojiCount, 
                int replaceStrategy)
```

Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found.


- If no emojis are found, `charSequence` given as the input is returned without any changes. i.e. charSequence is a String, and no emojis are found, the same String is returned.
- If the given input is not a Spannable (such as String), and at least one emoji is found a new [Spannable](https://developer.android.com/reference/android/text/Spannable.html) instance is returned.
- If the given input is a Spannable, the same instance is returned.

When used on devices running API 18 or below, returns the given `charSequence` without processing it.

<br />

<br />

|                                                                                                                                                                                                                                                                                           Parameters                                                                                                                                                                                                                                                                                            ||
|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `charSequence`    | `CharSequence`: CharSequence to add the EmojiSpans, cannot be `null` <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `start`           | `int`: start index in the charSequence to look for emojis, should be greater than or equal to `0`, also less than `charSequence.length()` <br />                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `end`             | `int`: end index in the charSequence to look for emojis, should be greater than or equal to `start` parameter, also less than `charSequence.length()` <br />                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `maxEmojiCount`   | `int`: maximum number of emojis in the `charSequence`, should be greater than or equal to `0` <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `replaceStrategy` | `int`: whether to replace all emoji with [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan)s, should be one of [REPLACE_STRATEGY_DEFAULT](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#REPLACE_STRATEGY_DEFAULT), [REPLACE_STRATEGY_NON_EXISTENT](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#REPLACE_STRATEGY_NON_EXISTENT), [REPLACE_STRATEGY_ALL](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#REPLACE_STRATEGY_ALL) <br /> |

|        Returns         ||
|----------------|--------|
| `CharSequence` | <br /> |

|                                                                                    Throws                                                                                     ||
|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `IllegalStateException`    | if not initialized yet                                                                                                                            |
| `IllegalArgumentException` | in the following cases: `start < 0`, `end < 0`, `end < start`, `start > charSequence.length()`, `end > charSequence.length()` `maxEmojiCount < 0` |

`


``

`  

### process

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CharSequence process (CharSequence charSequence, 
                int start, 
                int end, 
                int maxEmojiCount)
```

Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found.


- If no emojis are found, `charSequence` given as the input is returned without any changes. i.e. charSequence is a String, and no emojis are found, the same String is returned.
- If the given input is not a Spannable (such as String), and at least one emoji is found a new [Spannable](https://developer.android.com/reference/android/text/Spannable.html) instance is returned.
- If the given input is a Spannable, the same instance is returned.

When used on devices running API 18 or below, returns the given `charSequence` without processing it.

<br />

<br />

|                                                                                  Parameters                                                                                   ||
|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `charSequence`  | `CharSequence`: CharSequence to add the EmojiSpans, cannot be `null` <br />                                                                                  |
| `start`         | `int`: start index in the charSequence to look for emojis, should be greater than or equal to `0`, also less than `charSequence.length()` <br />             |
| `end`           | `int`: end index in the charSequence to look for emojis, should be greater than or equal to `start` parameter, also less than `charSequence.length()` <br /> |
| `maxEmojiCount` | `int`: maximum number of emojis in the `charSequence`, should be greater than or equal to `0` <br />                                                         |

|        Returns         ||
|----------------|--------|
| `CharSequence` | <br /> |

|                                                                                    Throws                                                                                     ||
|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `IllegalStateException`    | if not initialized yet                                                                                                                            |
| `IllegalArgumentException` | in the following cases: `start < 0`, `end < 0`, `end < start`, `start > charSequence.length()`, `end > charSequence.length()` `maxEmojiCount < 0` |

`


``

`  

### process

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CharSequence process (CharSequence charSequence, 
                int start, 
                int end)
```

Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found.


- If no emojis are found, `charSequence` given as the input is returned without any changes. i.e. charSequence is a String, and no emojis are found, the same String is returned.
- If the given input is not a Spannable (such as String), and at least one emoji is found a new [Spannable](https://developer.android.com/reference/android/text/Spannable.html) instance is returned.
- If the given input is a Spannable, the same instance is returned.

When used on devices running API 18 or below, returns the given `charSequence` without processing it.

<br />

<br />

|                                                                                  Parameters                                                                                  ||
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `charSequence` | `CharSequence`: CharSequence to add the EmojiSpans, cannot be `null` <br />                                                                                  |
| `start`        | `int`: start index in the charSequence to look for emojis, should be greater than or equal to `0`, also less than `charSequence.length()` <br />             |
| `end`          | `int`: end index in the charSequence to look for emojis, should be greater than or equal to `start` parameter, also less than `charSequence.length()` <br /> |

|        Returns         ||
|----------------|--------|
| `CharSequence` | <br /> |

|                                                                          Throws                                                                           ||
|----------------------------|-------------------------------------------------------------------------------------------------------------------------------|
| `IllegalStateException`    | if not initialized yet                                                                                                        |
| `IllegalArgumentException` | in the following cases: `start < 0`, `end < 0`, `end < start`, `start > charSequence.length()`, `end > charSequence.length()` |

`


``

`  

### registerInitCallback

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void registerInitCallback (EmojiCompat.InitCallback initCallback)
```

Registers an initialization callback. If the initialization is already completed by the time
the listener is added, the callback functions are called immediately. Callbacks are called on
the main looper.

<br />

When used on devices running API 18 or below, [onInitialized()](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.InitCallback#onInitialized()) is called without loading any metadata. In such cases [onFailed(Throwable)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.InitCallback#onFailed(java.lang.Throwable)) is never called.

<br />

<br />

|                                                  Parameters                                                  ||
|----------------|----------------------------------------------------------------------------------------------|
| `initCallback` | `EmojiCompat.InitCallback`: the initialization callback to register, cannot be `null` <br /> |

**See also:**

- [unregisterInitCallback(InitCallback)](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat#unregisterInitCallback(android.support.text.emoji.EmojiCompat.InitCallback))
`


``

`  

### unregisterInitCallback

added in [version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void unregisterInitCallback (EmojiCompat.InitCallback initCallback)
```

Unregisters a callback that was added before.

<br />

|                                           Parameters                                            ||
|----------------|---------------------------------------------------------------------------------|
| `initCallback` | `EmojiCompat.InitCallback`: the callback to be removed, cannot be `null` <br /> |

`


``


``

`
`


`
-

  ## Interfaces

  - [EmojiCompat.MetadataRepoLoader](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.MetadataRepoLoader)
-

  ## Classes

  - [EmojiCompat](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat)
  - [EmojiCompat.Config](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.Config)
  - [EmojiCompat.InitCallback](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.InitCallback)
  - [EmojiCompat.MetadataRepoLoaderCallback](https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.MetadataRepoLoaderCallback)
  - [EmojiSpan](https://developer.android.com/reference/android/support/text/emoji/EmojiSpan)
  - [FontRequestEmojiCompatConfig](https://developer.android.com/reference/android/support/text/emoji/FontRequestEmojiCompatConfig)
  - [FontRequestEmojiCompatConfig.ExponentialBackoffRetryPolicy](https://developer.android.com/reference/android/support/text/emoji/FontRequestEmojiCompatConfig.ExponentialBackoffRetryPolicy)
  - [FontRequestEmojiCompatConfig.RetryPolicy](https://developer.android.com/reference/android/support/text/emoji/FontRequestEmojiCompatConfig.RetryPolicy)
  - [MetadataRepo](https://developer.android.com/reference/android/support/text/emoji/MetadataRepo)
  - [R](https://developer.android.com/reference/android/support/text/emoji/R)
  - [R.attr](https://developer.android.com/reference/android/support/text/emoji/R.attr)
  - [R.bool](https://developer.android.com/reference/android/support/text/emoji/R.bool)
  - [R.color](https://developer.android.com/reference/android/support/text/emoji/R.color)
  - [R.dimen](https://developer.android.com/reference/android/support/text/emoji/R.dimen)
  - [R.drawable](https://developer.android.com/reference/android/support/text/emoji/R.drawable)
  - [R.id](https://developer.android.com/reference/android/support/text/emoji/R.id)
  - [R.integer](https://developer.android.com/reference/android/support/text/emoji/R.integer)
  - [R.layout](https://developer.android.com/reference/android/support/text/emoji/R.layout)
  - [R.string](https://developer.android.com/reference/android/support/text/emoji/R.string)
  - [R.style](https://developer.android.com/reference/android/support/text/emoji/R.style)
  - [R.styleable](https://developer.android.com/reference/android/support/text/emoji/R.styleable)
`


`
`


``

`