# EmojiCompat

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

*** ** * ** ***

<br />

```
@AnyThread
class EmojiCompat
```

<br />

*** ** * ** ***

Main class to keep Android devices up to date with the newest emojis by adding `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan`s to a given `https://developer.android.com/reference/java/lang/CharSequence.html`.
By default, EmojiCompat is initialized by `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompatInitializer`, which performs deferred font loading to avoid potential app startup delays. The default behavior is to load the font shortly after the first Activity resumes. EmojiCompatInitializer will configure EmojiCompat to use the system emoji font provider via `https://developer.android.com/reference/kotlin/androidx/emoji2/text/DefaultEmojiCompatConfig` and always creates a new background thread for font loading. EmojiCompat will only allow one instance to be initialized and any calls to `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#init(androidx.emoji2.text.EmojiCompat.Config)` after the first one will have no effect. As a result, configuration options may not be provided when using `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompatInitializer`. To provide a custom configuration, disable `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompatInitializer` in the manifest with:

```kotlin
    <provider
        android:name="androidx.startup.InitializationProvider"
        android:authorities="${applicationId}.androidx-startup"
        android:exported="false"
        tools:node="merge">
        <meta-data android:name="androidx.emoji2.text.EmojiCompatInitializer"
                  tools:node="remove" />
    </provider>
```
When not using EmojiCompatInitializer, EmojiCompat must to be initialized manually using `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#init(androidx.emoji2.text.EmojiCompat.Config)`. It is recommended to make the initialization as early as possible in your app, such as from `https://developer.android.com/reference/android/app/Application.html#onCreate()`. `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#init(androidx.emoji2.text.EmojiCompat.Config)` is fast and may be called from the main thread on the path to displaying the first activity. However, loading the emoji font takes significant resources on a background thread, so it is suggested to use `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#LOAD_STRATEGY_MANUAL()` in all manual configurations to defer font loading until after the first screen displays. Font loading may be started by calling `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#load()`}. See the implementation `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompatInitializer` for ideas when building a manual configuration. After initialization the `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#get()` function can be used to get the configured instance and the `https://developer.android.com/reference/kotlin/androidx/emoji2/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")
```
`` During loading information about emojis is not available. Before the EmojiCompat instance has finished loading, calls to functions such as `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#process(java.lang.CharSequence)` will throw an exception. It is safe to call process when `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getLoadState()` returns `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#LOAD_STATE_SUCCEEDED()`. To register a callback when loading completes use `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.InitCallback`. ``

## Summary

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

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#EDITOR_INFO_METAVERSION_KEY() = "android.support.text.emoji.emojiCompat_metadataVersion"` Key in `https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#extras` that represents the emoji metadata version used by the widget. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#EDITOR_INFO_REPLACE_ALL_KEY() = "android.support.text.emoji.emojiCompat_replaceAll"` Key in `https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#extras` that represents `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.Config#setReplaceAll(boolean)` configuration parameter. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#EMOJI_FALLBACK() = 2` Result of `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiMatch(java.lang.CharSequence,int)` that means the full codepoint sequence is not known to emojicompat, but at least one subsequence is an emoji that is known at this metadata level. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#EMOJI_SUPPORTED() = 1` Result of `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiMatch(java.lang.CharSequence,int)` that means this codepoint can be drawn by an `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan` at this metadata level. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#EMOJI_UNSUPPORTED() = 0` Result of `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiMatch(java.lang.CharSequence,int)` that means no part of this codepoint sequence will ever generate an `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan` at the requested metadata level. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#LOAD_STATE_DEFAULT() = 3` EmojiCompat instance is constructed, however the initialization did not start yet. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#LOAD_STATE_FAILED() = 2` An unrecoverable error occurred during initialization of EmojiCompat. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#LOAD_STATE_LOADING() = 0` EmojiCompat is initializing. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#LOAD_STATE_SUCCEEDED() = 1` EmojiCompat successfully initialized. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#LOAD_STRATEGY_DEFAULT() = 0` `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat` will start loading metadata when `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#init(androidx.emoji2.text.EmojiCompat.Config)` is called. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#LOAD_STRATEGY_MANUAL() = 1` `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat` will wait for `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#load()` to be called by developer in order to start loading metadata. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#REPLACE_STRATEGY_ALL() = 1` Replace strategy to add `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan`s for all emoji that were found. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#REPLACE_STRATEGY_DEFAULT() = 0` Replace strategy that uses the value given in `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.Config`. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#REPLACE_STRATEGY_NON_EXISTENT() = 2` Replace strategy to add `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan`s only for emoji that do not exist in the system. |

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#get()()` Return singleton EmojiCompat instance. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getAssetSignature()()` Returns signature for the currently loaded emoji assets. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiEnd(java.lang.CharSequence,int)(charSequence: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html, offset: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` see `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiStart(java.lang.CharSequence,int)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiMatch(java.lang.CharSequence,int)( sequence: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html, metadataVersion: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Attempts to lookup the entire sequence at the specified metadata version and returns what the runtime match behavior would be. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiStart(java.lang.CharSequence,int)(charSequence: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html, offset: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Together with `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiEnd(java.lang.CharSequence,int)`, if the character at `offset` is part of an emoji, returns the index range of that emoji, start index inclusively/end index exclusively so that `charSequence.subSequence(start, end)` will return that emoji. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getLoadState()()` Returns loading state of the EmojiCompat instance. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#handleDeleteSurroundingText(android.view.inputmethod.InputConnection,android.text.Editable,int,int,boolean)( inputConnection: https://developer.android.com/reference/android/view/inputmethod/InputConnection.html, editable: https://developer.android.com/reference/android/text/Editable.html, beforeLength: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, afterLength: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, inCodePoints: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Handles deleteSurroundingText commands from `https://developer.android.com/reference/android/view/inputmethod/InputConnection.html` and tries to delete an `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan` from an `https://developer.android.com/reference/android/text/Editable.html`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#handleOnKeyDown(android.text.Editable,int,android.view.KeyEvent)(editable: https://developer.android.com/reference/android/text/Editable.html, keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, event: https://developer.android.com/reference/android/view/KeyEvent.html)` Handles onKeyDown commands from a `https://developer.android.com/reference/android/text/method/KeyListener.html` and if `keyCode` is one of `https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_DEL` or `https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_FORWARD_DEL` it tries to delete an `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan` from an `https://developer.android.com/reference/android/text/Editable.html`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[hasEmojiGlyph](https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#hasEmojiGlyph(java.lang.CharSequence))(sequence: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` **This function is deprecated.** use getEmojiMatch which returns more accurate lookup information. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[hasEmojiGlyph](https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#hasEmojiGlyph(java.lang.CharSequence,int))( sequence: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html, metadataVersion: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` **This function is deprecated.** use getEmojiMatch which returns more accurate lookup information. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#init(androidx.emoji2.text.EmojiCompat.Config)(config: https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.Config)` Initialize the singleton instance with a configuration. |
| `java-static https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat?` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#init(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Initialize the singleton instance with the default system-provided configuration. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#isConfigured()()` Return true if EmojiCompat has been configured by a successful call to `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#init(android.content.Context)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#load()()` When `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.Config#setMetadataLoadStrategy(int)` is set to `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#LOAD_STRATEGY_MANUAL()`, this function starts loading the metadata. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#process(java.lang.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. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#process(java.lang.CharSequence,int,int)( charSequence: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?, start: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#process(java.lang.CharSequence,int,int,int)( charSequence: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?, start: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxEmojiCount: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#process(java.lang.CharSequence,int,int,int,int)( charSequence: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?, start: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, maxEmojiCount: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, replaceStrategy: 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. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#registerInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback)(initCallback: https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.InitCallback)` Registers an initialization callback. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#registerInitCallback(java.util.concurrent.Executor,androidx.emoji2.text.EmojiCompat.InitCallback)( executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, initCallback: https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.InitCallback )` Registers an initialization callback. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#unregisterInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback)(initCallback: https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.InitCallback)` Unregisters a callback that was added before. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#updateEditorInfo(android.view.inputmethod.EditorInfo)(outAttrs: https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html)` Updates the EditorInfo attributes in order to communicate information to Keyboards. |

## Constants

### EDITOR_INFO_METAVERSION_KEY

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

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

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

### EDITOR_INFO_REPLACE_ALL_KEY

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

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

Key in `https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#extras` that represents `https://developer.android.com/reference/kotlin/androidx/emoji2/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.

### EMOJI_FALLBACK

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

```
const val EMOJI_FALLBACK = 2: Int
```

Result of `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiMatch(java.lang.CharSequence,int)` that means the full codepoint sequence is not known to emojicompat, but at least one subsequence is an emoji that is known at this metadata level. Keyboards may decide that this emoji is not supported by the application when this result is returned, with no further processing. This return value implies: - EmojiCompat will decompose this ZWJ sequence into multiple glyphs when replaceAll=true - EmojiCompat MAY defer to platform when replaceAll=false - System emoji font may or may not support this emoji - This application MAY render this emoji This return value is only ever returned for ZWJ sequences. To understand this result consider when it may be returned for the multi-skin-tone handshake introduced in emoji 14.

```kotlin
    U+1FAF1 // unknown @ requested metadata level
    U+1F3FB // metadata level 1
    U+200D  // not displayed (ZWJ)
    U+1FAF2 // unknown @ requested metadata level
    U+1F3FD // metadata level 1
```
In this codepoint sequence, U+1F3FB and U+1F3FD are known from metadata level 1. When an application is using a metadata level that doesn't understand this ZWJ and provides `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#REPLACE_STRATEGY_ALL()` true, the color emoji are matched and replaced with `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan`. The system emoji font, even if it supports this ZWJ sequence, is never queried and the added EmojiSpans force fallback rendering for the ZWJ sequence. The glyph will only display correctly for this application if ALL of the following requirements are met: - `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#REPLACE_STRATEGY_ALL()` is false - `https://developer.android.com/reference/kotlin/androidx/core/graphics/PaintCompat#hasGlyph(android.graphics.Paint,java.lang.String)` returns true for each emoji subsequence known at this metadata level - `https://developer.android.com/reference/kotlin/androidx/core/graphics/PaintCompat#hasGlyph(android.graphics.Paint,java.lang.String)` returns true for the full sequence Given this return value for the multi-skin-tone handshake above, if `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#REPLACE_STRATEGY_ALL()` is false then the emoji will display if the entire emoji sequence is matched by `https://developer.android.com/reference/kotlin/androidx/core/graphics/PaintCompat#hasGlyph(android.graphics.Paint,java.lang.String)` because U+1F3FB and U+1F3FD are both in the system emoji font. Keyboards that wish to determine if the glyph will display correctly by the application in response to this return value should consider building an internal lookup for new ZWJ sequences instead of repeatedly calling `https://developer.android.com/reference/kotlin/androidx/core/graphics/PaintCompat#hasGlyph(android.graphics.Paint,java.lang.String)` for each emoji subsequence.

### EMOJI_SUPPORTED

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

```
const val EMOJI_SUPPORTED = 1: Int
```

Result of `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiMatch(java.lang.CharSequence,int)` that means this codepoint can be drawn by an `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan` at this metadata level. No further checks are required by keyboards for this result. The emoji is always supported by this application. This return value implies: - EmojiCompat can draw this emoji - System emoji font may or may not support this emoji - This application WILL render this emoji This result implies that EmojiCompat can successfully display this emoji. The system emoji font is not checked by this method, and this result may be returned even if the platform also supports the emoji sequence. If the application passes `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#REPLACE_STRATEGY_ALL()` of true, then an `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan` will always be generated for this emoji. If the application passes `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#REPLACE_STRATEGY_ALL()` of false, then an `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan` will only be generated if `https://developer.android.com/reference/kotlin/androidx/core/graphics/PaintCompat#hasGlyph(android.graphics.Paint,java.lang.String)` returns false for this emoji.

### EMOJI_UNSUPPORTED

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

```
const val EMOJI_UNSUPPORTED = 0: Int
```

Result of `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiMatch(java.lang.CharSequence,int)` that means no part of this codepoint sequence will ever generate an `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan` at the requested metadata level. This return value implies: - EmojiCompat will always defer to system emoji font - System emoji font may or may not support this emoji - This application MAY render this emoji This can be used by keyboards to learn that EmojiCompat does not support this codepoint sequence at this metadata version. The system emoji font is not checked by this method, and this result will be returned even if the system emoji font supports the emoji. This may happen if the application is using an older version of the emoji compat font than the system emoji font. Keyboards may optionally determine that the system emoji font will support the emoji, for example by building a internal lookup table or calling `https://developer.android.com/reference/kotlin/androidx/core/graphics/PaintCompat#hasGlyph(android.graphics.Paint,java.lang.String)` to query the system emoji font. Keyboards may use a lookup table to optimize this check, however they should be aware that OEMs may add or remove emoji from the system emoji font. Keyboards may finally decide: - If the system emoji font DOES NOT support the emoji, then the emoji IS NOT supported by this application. - If the system emoji font DOES support the emoji, then the emoji IS supported by this application. - If system emoji font is support is UNKNOWN, then assume the emoji IS NOT supported by this application.

### LOAD_STATE_DEFAULT

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

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

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

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

### LOAD_STATE_FAILED

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

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

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

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

### LOAD_STATE_LOADING

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

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

EmojiCompat is initializing.

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

### LOAD_STATE_SUCCEEDED

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

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

EmojiCompat successfully initialized.

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

### LOAD_STRATEGY_DEFAULT

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

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

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

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

### LOAD_STRATEGY_MANUAL

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

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

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

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

### REPLACE_STRATEGY_ALL

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

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

Replace strategy to add `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan`s for all emoji that were found.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/emoji2/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/emoji2#1.0.0)

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

Replace strategy that uses the value given in `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.Config`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/emoji2/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/emoji2#1.0.0)

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

Replace strategy to add `https://developer.android.com/reference/kotlin/androidx/emoji2/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/emoji2#1.0.0)

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

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat` | EmojiCompat instance |

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

### getAssetSignature

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji2#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 |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if not initialized yet |

### getEmojiEnd

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

```
fun getEmojiEnd(charSequence: CharSequence, offset: @IntRange(from = 0) Int): Int
```

see `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiStart(java.lang.CharSequence,int)`.

### getEmojiMatch

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

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

Attempts to lookup the entire sequence at the specified metadata version and returns what the runtime match behavior would be. To be used by keyboards to show or hide emoji in response to specific metadata support.

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A match result, or decomposes if replaceAll would cause partial subsequence matches. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#EMOJI_SUPPORTED()` |   |
| `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#EMOJI_UNSUPPORTED()` |   |
| `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#EMOJI_FALLBACK()` |   |

### getEmojiStart

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

```
fun getEmojiStart(charSequence: CharSequence, offset: @IntRange(from = 0) Int): Int
```

Together with `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getEmojiEnd(java.lang.CharSequence,int)`, if the character at `offset` is part of an emoji, returns the index range of that emoji, start index inclusively/end index exclusively so that `charSequence.subSequence(start, end)` will return that emoji. E.g., getEmojiStart/End("AB😀", 1) will return (-1,-1) since 'B' is not part an emoji; getEmojiStart/End("AB😀", 3) will return \[2,4), note that "😀" contains 2 Chars. Returns -1 otherwise.

| Parameters |
|---|---|
| `charSequence: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` | the whole sequence |
| `offset: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | index of the emoji to look up |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the start index inclusively/end index exclusively |

### getLoadState

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

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

Returns loading state of the EmojiCompat instance. When used on devices running API 18 or below always returns `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#LOAD_STATE_SUCCEEDED()`.

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

### handleDeleteSurroundingText

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji2#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 `https://developer.android.com/reference/android/view/inputmethod/InputConnection.html` and tries to delete an `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan` from an `https://developer.android.com/reference/android/text/Editable.html`. Returns `true` if an `https://developer.android.com/reference/kotlin/androidx/emoji2/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: https://developer.android.com/reference/android/view/inputmethod/InputConnection.html` | InputConnection instance |
| `editable: https://developer.android.com/reference/android/text/Editable.html` | TextView.Editable instance |
| `beforeLength: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the number of characters before the cursor to be deleted |
| `afterLength: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the number of characters after the cursor to be deleted |
| `inCodePoints: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if length parameters are in codepoints |

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

### handleOnKeyDown

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

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

Handles onKeyDown commands from a `https://developer.android.com/reference/android/text/method/KeyListener.html` and if `keyCode` is one of `https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_DEL` or `https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_FORWARD_DEL` it tries to delete an `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan` from an `https://developer.android.com/reference/android/text/Editable.html`. Returns `true` if an `https://developer.android.com/reference/kotlin/androidx/emoji2/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: https://developer.android.com/reference/android/text/Editable.html` | Editable instance passed to `https://developer.android.com/reference/android/text/method/KeyListener.html#onKeyDown(android.view.View, android.text.Editable, int, android.view.KeyEvent)` |
| `keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | keyCode passed to `https://developer.android.com/reference/android/text/method/KeyListener.html#onKeyDown(android.view.View, android.text.Editable, int, android.view.KeyEvent)` |
| `event: https://developer.android.com/reference/android/view/KeyEvent.html` | KeyEvent passed to `https://developer.android.com/reference/android/text/method/KeyListener.html#onKeyDown(android.view.View, android.text.Editable, int, android.view.KeyEvent)` |

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

### hasEmojiGlyph

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

```
fun [hasEmojiGlyph](https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#hasEmojiGlyph(java.lang.CharSequence))(sequence: CharSequence): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use getEmojiMatch which returns more accurate lookup information.

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

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

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

| Throws |
|---|---|
| `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/emoji2#1.0.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/emoji2#1.1.0)

```
fun [hasEmojiGlyph](https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#hasEmojiGlyph(java.lang.CharSequence,int))(
    sequence: CharSequence,
    metadataVersion: @IntRange(from = 0) Int
): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use getEmojiMatch which returns more accurate lookup information.

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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` | CharSequence representing the emoji |
| `metadataVersion: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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 |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if EmojiCompat can render given emoji, cannot be `null` |

| Throws |
|---|---|
| `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/emoji2#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 `https://developer.android.com/reference/kotlin/androidx/emoji2/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 |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.Config` |   |

### init

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

```
java-static fun init(context: Context): EmojiCompat?
```

Initialize the singleton instance with the default system-provided configuration.

This is the recommended configuration for most applications. For more details see `https://developer.android.com/reference/kotlin/androidx/emoji2/text/DefaultEmojiCompatConfig`.

This call will use `https://developer.android.com/reference/kotlin/androidx/emoji2/text/DefaultEmojiCompatConfig` to lookup the default emoji font provider installed on the system and use that, if present. If there is no default font provider onthe system, this call will have no effect.

Note: EmojiCompat may only be initialized once, and will return the same instance afterwords.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat?` | Default EmojiCompat for this device, or null if there is no provider on the system. |

### isConfigured

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

```
java-static fun isConfigured(): Boolean
```

Return true if EmojiCompat has been configured by a successful call to `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#init(android.content.Context)`. You can use this to check if `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#get()` will return a valid EmojiCompat instance. This function does not check the `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#getLoadState()` and will return true even if the font is still loading, or has failed to load.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true if EmojiCompat has been successfully initialized. |

### load

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

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

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

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

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

### process

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji2#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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | CharSequence to add the EmojiSpans |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if not initialized yet |

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

### process

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji2#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 `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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | CharSequence to add the EmojiSpans, cannot be `null` |
| `start: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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 |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if not initialized yet |
| `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/emoji2#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 `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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | CharSequence to add the EmojiSpans, cannot be `null` |
| `start: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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 |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if not initialized yet |
| `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/emoji2#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 `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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | CharSequence to add the EmojiSpans, cannot be `null` |
| `start: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | whether to replace all emoji with `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiSpan`s, should be one of `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#REPLACE_STRATEGY_DEFAULT()`, `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#REPLACE_STRATEGY_NON_EXISTENT()`, `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#REPLACE_STRATEGY_ALL()` |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if not initialized yet |
| `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/emoji2#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, `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.InitCallback#onInitialized()` is called without loading any metadata. In such cases `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.InitCallback#onFailed(java.lang.Throwable)` is never called.

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

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

### registerInitCallback

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

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

| Parameters |
|---|---|
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | executor to dispatch callback on |
| `initCallback: https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat.InitCallback` | the initialization callback to register, cannot be `null` |

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

### unregisterInitCallback

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

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

Unregisters a callback that was added before.

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

### updateEditorInfo

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

```
fun updateEditorInfo(outAttrs: EditorInfo): Unit
```

Updates the EditorInfo attributes in order to communicate information to Keyboards. When used on devices running API 18 or below, does not update EditorInfo attributes. This is called from EditText integrations that use EmojiEditTextHelper. Custom widgets that allow IME not subclassing EditText should call this method when creating an input connection. When EmojiCompat is not in `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#LOAD_STATE_SUCCEEDED()`, this method has no effect. Calling this method on API levels below API 19 will have no effect, as EmojiCompat may never be configured. However, it is always safe to call, even on older API levels.

| Parameters |
|---|---|
| `outAttrs: https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html` | EditorInfo instance passed to `https://developer.android.com/reference/android/widget/TextView.html#onCreateInputConnection(android.view.inputmethod.EditorInfo)` |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#EDITOR_INFO_METAVERSION_KEY()` |   |
| `https://developer.android.com/reference/kotlin/androidx/emoji2/text/EmojiCompat#EDITOR_INFO_REPLACE_ALL_KEY()` |   |