# EmojiCompat

# EmojiCompat

Artifact:[androidx.emoji:emoji](https://developer.android.com/jetpack/androidx/releases/emoji)  
[View Source](https://cs.android.com/search?q=file:androidx/emoji/text/EmojiCompat.java+class:androidx.emoji.text.EmojiCompat)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/emoji/text/EmojiCompat "View this page in Java")

<br />

```
@AnyThread
class EmojiCompat
```

<br />

*** ** * ** ***

Main class to keep Android devices up to date with the newest emojis by adding[EmojiSpan](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiSpan)s to a given[CharSequence](https://developer.android.com/reference/java/lang/CharSequence.html). It is a singleton class that can be configured using a[EmojiCompat.Config](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config)instance.
EmojiCompat has to be initialized using[init](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#init(androidx.emoji.text.EmojiCompat.Config))function before it can process a[CharSequence](https://developer.android.com/reference/java/lang/CharSequence.html).  

```kotlin
EmojiCompat.init(/* a config instance */);
```
It is suggested to make the initialization as early as possible in your app. Please check[EmojiCompat.Config](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config)for more configuration parameters. Once[init](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#init(androidx.emoji.text.EmojiCompat.Config))is called a singleton instance will be created. Any call after that will not create a new instance and will return immediately. During initialization information about emojis is loaded on a background thread. Before the EmojiCompat instance is initialized, calls to functions such as[process](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#process(java.lang.CharSequence))will throw an exception. You can use the[InitCallback](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.InitCallback)class to be informed about the state of initialization. After initialization the[get](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#get())function can be used to get the configured instance and the[process](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#process(java.lang.CharSequence))function can be used to update a CharSequence with emoji EmojiSpans.  

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

## Summary

|                                                                                                             ### Nested types                                                                                                              |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abstract class `[EmojiCompat.Config](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config) Configuration class for EmojiCompat.                                                                         |
| `interface `[EmojiCompat.GlyphChecker](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.GlyphChecker) Interface to check if a given emoji exists on the system.                                             |
| `abstract class `[EmojiCompat.InitCallback](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.InitCallback) Listener class for the initialization of the EmojiCompat.                                        |
| `interface `[EmojiCompat.MetadataRepoLoader](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.MetadataRepoLoader) Interface to load emoji metadata.                                                         |
| `abstract class `[EmojiCompat.MetadataRepoLoaderCallback](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.MetadataRepoLoaderCallback) Callback to inform EmojiCompat about the state of the metadata load. |

|                                        ### Constants                                         |
|----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | [EDITOR_INFO_METAVERSION_KEY](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#EDITOR_INFO_METAVERSION_KEY())` = "android.support.text.emoji.emojiCompat_metadataVersion"` Key in[extras](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#extras())that represents the emoji metadata version used by the widget.                                                                                                  |
| `const `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | [EDITOR_INFO_REPLACE_ALL_KEY](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#EDITOR_INFO_REPLACE_ALL_KEY())` = "android.support.text.emoji.emojiCompat_replaceAll"` Key in[extras](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#extras())that represents[setReplaceAll](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config#setReplaceAll(boolean))configuration parameter. |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | [LOAD_STATE_DEFAULT](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_DEFAULT())` = 3` EmojiCompat instance is constructed, however the initialization did not start yet.                                                                                                                                                                                                                                                                |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | [LOAD_STATE_FAILED](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_FAILED())` = 2` An unrecoverable error occurred during initialization of EmojiCompat.                                                                                                                                                                                                                                                                               |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | [LOAD_STATE_LOADING](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_LOADING())` = 0` EmojiCompat is initializing.                                                                                                                                                                                                                                                                                                                      |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | [LOAD_STATE_SUCCEEDED](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_SUCCEEDED())` = 1` EmojiCompat successfully initialized.                                                                                                                                                                                                                                                                                                         |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | [LOAD_STRATEGY_DEFAULT](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STRATEGY_DEFAULT())` = 0` [EmojiCompat](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat)will start loading metadata when[init](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#init(androidx.emoji.text.EmojiCompat.Config))is called.                                                                  |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | [LOAD_STRATEGY_MANUAL](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STRATEGY_MANUAL())` = 1` [EmojiCompat](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat)will wait for[load](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#load())to be called by developer in order to start loading metadata.                                                                          |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | [REPLACE_STRATEGY_ALL](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#REPLACE_STRATEGY_ALL())` = 1` Replace strategy to add[EmojiSpan](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiSpan)s for all emoji that were found.                                                                                                                                                                                              |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | [REPLACE_STRATEGY_DEFAULT](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#REPLACE_STRATEGY_DEFAULT())` = 0` Replace strategy that uses the value given in[EmojiCompat.Config](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config).                                                                                                                                                                             |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | [REPLACE_STRATEGY_NON_EXISTENT](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#REPLACE_STRATEGY_NON_EXISTENT())` = 2` Replace strategy to add[EmojiSpan](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiSpan)s only for emoji that do not exist in the system.                                                                                                                                                           |

|                                              ### Public functions                                              |
|----------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[EmojiCompat](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat)`!` | [get](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#get())`()` Return singleton EmojiCompat instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                              | [getAssetSignature](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#getAssetSignature())`()` Returns signature for the currently loaded emoji assets.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                    | [getLoadState](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#getLoadState())`()` Returns loading state of the EmojiCompat instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)              | [handleDeleteSurroundingText](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#handleDeleteSurroundingText(android.view.inputmethod.InputConnection,android.text.Editable,int,int,boolean))`(` ` inputConnection: `[InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html)`,` ` editable: `[Editable](https://developer.android.com/reference/android/text/Editable.html)`,` ` beforeLength: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` afterLength: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` inCodePoints: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) `)` 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/kotlin/androidx/emoji/text/EmojiSpan)from an[Editable](https://developer.android.com/reference/android/text/Editable.html). |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)              | [handleOnKeyDown](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#handleOnKeyDown(android.text.Editable,int,android.view.KeyEvent))`(editable: `[Editable](https://developer.android.com/reference/android/text/Editable.html)`, keyCode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, event: `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)`!)` 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/kotlin/androidx/emoji/text/EmojiSpan)from an[Editable](https://developer.android.com/reference/android/text/Editable.html).                                                                                                                                                                                                                                                                                                            |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                            | [hasEmojiGlyph](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#hasEmojiGlyph(java.lang.CharSequence))`(sequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`)` Returns`true`if EmojiCompat is capable of rendering an emoji.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                            | [hasEmojiGlyph](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#hasEmojiGlyph(java.lang.CharSequence,int))`(` ` sequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`,` ` metadataVersion: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Returns`true`if EmojiCompat is capable of rendering an emoji at the given metadata version.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `java-static `[EmojiCompat](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat)`!` | [init](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#init(androidx.emoji.text.EmojiCompat.Config))`(config: `[EmojiCompat.Config](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config)`)` Initialize the singleton instance with a configuration.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [load](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#load())`()` When[setMetadataLoadStrategy](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config#setMetadataLoadStrategy(int))is set to[LOAD_STRATEGY_MANUAL](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STRATEGY_MANUAL()), this function starts loading the metadata.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!`              | [process](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#process(java.lang.CharSequence))`(charSequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`)` Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!`              | [process](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#process(java.lang.CharSequence,int,int))`(` ` charSequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`,` ` start: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` end: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!`              | [process](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#process(java.lang.CharSequence,int,int,int))`(` ` charSequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`,` ` start: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` end: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` maxEmojiCount: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found.                                                                                                                                                                                                                                                                                                                                                                                      |
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!`              | [process](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#process(java.lang.CharSequence,int,int,int,int))`(` ` charSequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`,` ` start: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` end: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` maxEmojiCount: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` replaceStrategy: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Checks a given CharSequence for emojis, and adds EmojiSpans if any emojis are found.                                                                                                                                                                                                                                                                               |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [registerInitCallback](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#registerInitCallback(androidx.emoji.text.EmojiCompat.InitCallback))`(initCallback: `[EmojiCompat.InitCallback](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.InitCallback)`)` Registers an initialization callback.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [unregisterInitCallback](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#unregisterInitCallback(androidx.emoji.text.EmojiCompat.InitCallback))`(initCallback: `[EmojiCompat.InitCallback](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.InitCallback)`)` Unregisters a callback that was added before.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

## Constants

### EDITOR_INFO_METAVERSION_KEY

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
const val EDITOR_INFO_METAVERSION_KEY = "android.support.text.emoji.emojiCompat_metadataVersion": String!
```

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.
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](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#hasEmojiGlyph(java.lang.CharSequence,int)).  

### EDITOR_INFO_REPLACE_ALL_KEY

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
const val EDITOR_INFO_REPLACE_ALL_KEY = "android.support.text.emoji.emojiCompat_replaceAll": String!
```

Key in[extras](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#extras())that represents[setReplaceAll](https://developer.android.com/reference/kotlin/androidx/emoji/text/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.  

### LOAD_STATE_DEFAULT

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
const val LOAD_STATE_DEFAULT = 3: Int
```

EmojiCompat instance is constructed, however the initialization did not start yet.  

|                                                   See also                                                    |
|---------------------------------------------------------------------------------------------------------------|---|
| [getLoadState](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#getLoadState()) |   |

### LOAD_STATE_FAILED

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
const val LOAD_STATE_FAILED = 2: Int
```

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

|                                                   See also                                                    |
|---------------------------------------------------------------------------------------------------------------|---|
| [getLoadState](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#getLoadState()) |   |

### LOAD_STATE_LOADING

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
const val LOAD_STATE_LOADING = 0: Int
```

EmojiCompat is initializing.  

|                                                   See also                                                    |
|---------------------------------------------------------------------------------------------------------------|---|
| [getLoadState](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#getLoadState()) |   |

### LOAD_STATE_SUCCEEDED

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
const val LOAD_STATE_SUCCEEDED = 1: Int
```

EmojiCompat successfully initialized.  

|                                                   See also                                                    |
|---------------------------------------------------------------------------------------------------------------|---|
| [getLoadState](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#getLoadState()) |   |

### LOAD_STRATEGY_DEFAULT

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
const val LOAD_STRATEGY_DEFAULT = 0: Int
```

[EmojiCompat](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat)will start loading metadata when[init](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#init(androidx.emoji.text.EmojiCompat.Config))is called.  

|                                                                   See also                                                                    |
|-----------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setMetadataLoadStrategy](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config#setMetadataLoadStrategy(int)) |   |

### LOAD_STRATEGY_MANUAL

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
const val LOAD_STRATEGY_MANUAL = 1: Int
```

[EmojiCompat](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat)will wait for[load](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#load())to be called by developer in order to start loading metadata.  

|                                                                   See also                                                                    |
|-----------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setMetadataLoadStrategy](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config#setMetadataLoadStrategy(int)) |   |

### REPLACE_STRATEGY_ALL

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
const val REPLACE_STRATEGY_ALL = 1: Int
```

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

|                                                                 See also                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------|---|
| [process](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#process(java.lang.CharSequence,int,int,int,int)) |   |

### REPLACE_STRATEGY_DEFAULT

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
const val REPLACE_STRATEGY_DEFAULT = 0: Int
```

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

|                                                                 See also                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------|---|
| [process](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#process(java.lang.CharSequence,int,int,int,int)) |   |

### REPLACE_STRATEGY_NON_EXISTENT

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
const val REPLACE_STRATEGY_NON_EXISTENT = 2: Int
```

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

## Public functions

### get

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
java-static fun get(): EmojiCompat!
```

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

|                                             Returns                                              |
|--------------------------------------------------------------------------------------------------|----------------------|
| [EmojiCompat](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat)`!` | EmojiCompat instance |

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if called before[init](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#init(androidx.emoji.text.EmojiCompat.Config)) |

### getAssetSignature

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun getAssetSignature(): String
```

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.  

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if not initialized yet |

### getLoadState

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun getLoadState(): Int
```

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/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_SUCCEEDED()).  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | one of[LOAD_STATE_DEFAULT](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_DEFAULT()),[LOAD_STATE_LOADING](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_LOADING()),[LOAD_STATE_SUCCEEDED](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_SUCCEEDED()),[LOAD_STATE_FAILED](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_FAILED()) |

### handleDeleteSurroundingText

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
java-static fun handleDeleteSurroundingText(
    inputConnection: InputConnection,
    editable: Editable,
    beforeLength: @IntRange(from = 0) Int,
    afterLength: @IntRange(from = 0) Int,
    inCodePoints: Boolean
): Boolean
```

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/kotlin/androidx/emoji/text/EmojiSpan)from an[Editable](https://developer.android.com/reference/android/text/Editable.html). Returns`true`if an[EmojiSpan](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiSpan)is deleted.
If there is a selection where selection start is not equal to selection end, does not delete. When used on devices running API 18 or below, always returns`false`.  

|                                                                                            Parameters                                                                                            |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| `inputConnection: `[InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html)                                                                      | InputConnection instance                                 |
| `editable: `[Editable](https://developer.android.com/reference/android/text/Editable.html)                                                                                                       | TextView.Editable instance                               |
| `beforeLength: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the number of characters before the cursor to be deleted |
| `afterLength: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)  | the number of characters after the cursor to be deleted  |
| `inCodePoints: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                              | `true`if length parameters are in codepoints             |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if an[EmojiSpan](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiSpan)is deleted |

### handleOnKeyDown

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
java-static fun handleOnKeyDown(editable: Editable, keyCode: Int, event: KeyEvent!): Boolean
```

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/kotlin/androidx/emoji/text/EmojiSpan)from an[Editable](https://developer.android.com/reference/android/text/Editable.html). Returns`true`if an[EmojiSpan](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiSpan)is deleted with the characters it covers.
If there is a selection where selection start is not equal to selection end, does not delete. When used on devices running API 18 or below, always returns`false`.  

|                                         Parameters                                         |
|--------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `editable: `[Editable](https://developer.android.com/reference/android/text/Editable.html) | Editable instance passed to[onKeyDown](https://developer.android.com/reference/android/text/method/KeyListener.html#onKeyDown(android.view.View, android.text.Editable, int, android.view.KeyEvent)) |
| `keyCode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)     | keyCode passed to[onKeyDown](https://developer.android.com/reference/android/text/method/KeyListener.html#onKeyDown(android.view.View, android.text.Editable, int, android.view.KeyEvent))           |
| `event: `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)`!` | KeyEvent passed to[onKeyDown](https://developer.android.com/reference/android/text/method/KeyListener.html#onKeyDown(android.view.View, android.text.Editable, int, android.view.KeyEvent))          |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if an[EmojiSpan](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiSpan)is deleted |

### hasEmojiGlyph

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun hasEmojiGlyph(sequence: CharSequence): Boolean
```

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

|                                                 Parameters                                                 |
|------------------------------------------------------------------------------------------------------------|-------------------------------------|
| `sequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html) | CharSequence representing the emoji |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if EmojiCompat can render given emoji, cannot be`null` |

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if not initialized yet |

### hasEmojiGlyph

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun hasEmojiGlyph(
    sequence: CharSequence,
    metadataVersion: @IntRange(from = 0) Int
): Boolean
```

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`.  

|                                                                                             Parameters                                                                                              |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| `sequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)                                                                                          | CharSequence representing the emoji                                           |
| `metadataVersion: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the metadata version to check against, should be greater than or equal to`0`, |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if EmojiCompat can render given emoji, cannot be`null` |

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if not initialized yet |

### init

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
java-static fun init(config: EmojiCompat.Config): EmojiCompat!
```

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/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_SUCCEEDED())state without loading any metadata. When called for the first time, the library will create the singleton instance and any call after that will not create a new instance and return immediately.  

|                                                  See also                                                   |
|-------------------------------------------------------------------------------------------------------------|---|
| [EmojiCompat.Config](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config) |   |

### load

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun load(): Unit
```

When[setMetadataLoadStrategy](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config#setMetadataLoadStrategy(int))is set to[LOAD_STRATEGY_MANUAL](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STRATEGY_MANUAL()), this function starts loading the metadata. Calling the function when[setMetadataLoadStrategy](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config#setMetadataLoadStrategy(int))is`not`set to[LOAD_STRATEGY_MANUAL](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STRATEGY_MANUAL())will throw an exception. The load will`not`start if:

- the metadata is already loaded successfully and[getLoadState](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#getLoadState())is[LOAD_STATE_SUCCEEDED](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_SUCCEEDED()).
- a previous load attempt is not finished yet and[getLoadState](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#getLoadState())is[LOAD_STATE_LOADING](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STATE_LOADING()).

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | when[setMetadataLoadStrategy](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.Config#setMetadataLoadStrategy(int))is not set to[LOAD_STRATEGY_MANUAL](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#LOAD_STRATEGY_MANUAL()) |

### process

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun process(charSequence: 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.  

|                                                   Parameters                                                   |
|----------------------------------------------------------------------------------------------------------------|------------------------------------|
| `charSequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html) | CharSequence to add the EmojiSpans |

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if not initialized yet |

|                                                             See also                                                              |
|-----------------------------------------------------------------------------------------------------------------------------------|---|
| [process](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#process(java.lang.CharSequence,int,int)) |   |

### process

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun process(
    charSequence: CharSequence,
    start: @IntRange(from = 0) Int,
    end: @IntRange(from = 0) Int
): CharSequence!
```

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[android.text.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.  

|                                                                                        Parameters                                                                                         |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| `charSequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)                                                                            | CharSequence to add the EmojiSpans, cannot be`null`                                                                                                     |
| `start: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | start index in the charSequence to look for emojis, should be greater than or equal to`0`, also less than or equal to`charSequence.length()`            |
| `end: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | end index in the charSequence to look for emojis, should be greater than or equal to`start`parameter, also less than or equal to`charSequence.length()` |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html)       | if not initialized yet                                                                                                   |
| [java.lang.IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | in the following cases:`start < 0`,`end < 0`,`end < start`,`start > charSequence.length()`,`end > charSequence.length()` |

### process

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun process(
    charSequence: CharSequence,
    start: @IntRange(from = 0) Int,
    end: @IntRange(from = 0) Int,
    maxEmojiCount: @IntRange(from = 0) Int
): CharSequence!
```

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[android.text.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.  

|                                                                                            Parameters                                                                                             |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| `charSequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)                                                                                    | CharSequence to add the EmojiSpans, cannot be`null`                                                                                                     |
| `start: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | start index in the charSequence to look for emojis, should be greater than or equal to`0`, also less than or equal to`charSequence.length()`            |
| `end: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)           | end index in the charSequence to look for emojis, should be greater than or equal to`start`parameter, also less than or equal to`charSequence.length()` |
| `maxEmojiCount: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | maximum number of emojis in the`charSequence`, should be greater than or equal to`0`                                                                    |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html)       | if not initialized yet                                                                                                                      |
| [java.lang.IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | in the following cases:`start < 0`,`end < 0`,`end < start`,`start > charSequence.length()`,`end > charSequence.length()``maxEmojiCount < 0` |

### process

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun process(
    charSequence: CharSequence,
    start: @IntRange(from = 0) Int,
    end: @IntRange(from = 0) Int,
    maxEmojiCount: @IntRange(from = 0) Int,
    replaceStrategy: Int
): CharSequence!
```

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[android.text.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.  

|                                                                                            Parameters                                                                                             |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `charSequence: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)                                                                                    | CharSequence to add the EmojiSpans, cannot be`null`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `start: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | start index in the charSequence to look for emojis, should be greater than or equal to`0`, also less than or equal to`charSequence.length()`                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `end: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)           | end index in the charSequence to look for emojis, should be greater than or equal to`start`parameter, also less than or equal to`charSequence.length()`                                                                                                                                                                                                                                                                                                                                                                                                          |
| `maxEmojiCount: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | maximum number of emojis in the`charSequence`, should be greater than or equal to`0`                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `replaceStrategy: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                    | whether to replace all emoji with[EmojiSpan](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiSpan)s, should be one of[REPLACE_STRATEGY_DEFAULT](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#REPLACE_STRATEGY_DEFAULT()),[REPLACE_STRATEGY_NON_EXISTENT](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#REPLACE_STRATEGY_NON_EXISTENT()),[REPLACE_STRATEGY_ALL](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#REPLACE_STRATEGY_ALL()) |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html)       | if not initialized yet                                                                                                                      |
| [java.lang.IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | in the following cases:`start < 0`,`end < 0`,`end < start`,`start > charSequence.length()`,`end > charSequence.length()``maxEmojiCount < 0` |

### registerInitCallback

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun registerInitCallback(initCallback: EmojiCompat.InitCallback): Unit
```

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.
When used on devices running API 18 or below,[onInitialized](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.InitCallback#onInitialized())is called without loading any metadata. In such cases[onFailed](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.InitCallback#onFailed(java.lang.Throwable))is never called.  

|                                                               Parameters                                                                |
|-----------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| `initCallback: `[EmojiCompat.InitCallback](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.InitCallback) | the initialization callback to register, cannot be`null` |

|                                                                                   See also                                                                                    |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [unregisterInitCallback](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat#unregisterInitCallback(androidx.emoji.text.EmojiCompat.InitCallback)) |   |

### unregisterInitCallback

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun unregisterInitCallback(initCallback: EmojiCompat.InitCallback): Unit
```

Unregisters a callback that was added before.  

|                                                               Parameters                                                                |
|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|
| `initCallback: `[EmojiCompat.InitCallback](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat.InitCallback) | the callback to be removed, cannot be`null` |