# EmojiCompat.Config

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

*** ** * ** ***


```
public abstract class EmojiCompat.Config
```

<br />

Known direct subclasses [BundledEmojiCompatConfig](https://developer.android.com/reference/androidx/emoji2/bundled/BundledEmojiCompatConfig), [FontRequestEmojiCompatConfig](https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig)

|---|---|
| `https://developer.android.com/reference/androidx/emoji2/bundled/BundledEmojiCompatConfig` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` implementation that loads the metadata using AssetManager and bundled resources. |
| `https://developer.android.com/reference/androidx/emoji2/text/FontRequestEmojiCompatConfig` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` implementation that asynchronously fetches the required font and the metadata using a `https://developer.android.com/reference/androidx/core/provider/FontRequest`. |

*** ** * ** ***

Configuration class for EmojiCompat. Changes to the values will be ignored after `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#init(androidx.emoji2.text.EmojiCompat.Config)` is called.

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

## Summary

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#Config(androidx.emoji2.text.EmojiCompat.MetadataRepoLoader)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.MetadataRepoLoader metadataLoader)` Default constructor. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#registerInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.InitCallback initCallback)` Registers an initialization callback. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#registerInitCallback(java.util.concurrent.Executor,androidx.emoji2.text.EmojiCompat.InitCallback)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.InitCallback initCallback )` Registers an initialization callback. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setEmojiSpanIndicatorColor(int)(@https://developer.android.com/reference/androidx/annotation/ColorInt int color)` Sets the color used as emoji span indicator. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setEmojiSpanIndicatorEnabled(boolean)(boolean emojiSpanIndicatorEnabled)` Determines whether a background will be drawn for the emojis that are found and replaced by EmojiCompat. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setGlyphChecker(androidx.emoji2.text.EmojiCompat.GlyphChecker)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.GlyphChecker glyphChecker)` The interface that is used by EmojiCompat in order to check if a given emoji can be rendered by the system. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setMetadataLoadStrategy(int)(int strategy)` Determines the strategy to start loading the metadata. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setReplaceAll(boolean)(boolean replaceAll)` Determines whether EmojiCompat should replace all the emojis it finds with the EmojiSpans. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setSpanFactory(androidx.emoji2.text.EmojiCompat.SpanFactory)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.SpanFactory factory)` Set the span factory used to actually draw emoji replacements. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setUseAfterUpdatableSystemFonts(boolean)(boolean useAfter)` Configure whether EmojiCompat should continue to process emojis and load metadata on devices that support Updatable System Fonts (API 35 and above). |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setUseEmojiAsDefaultStyle(boolean)(boolean useEmojiAsDefaultStyle)` Determines whether EmojiCompat should use the emoji presentation style for emojis that have text style as default. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setUseEmojiAsDefaultStyle(boolean,java.util.List<java.lang.Integer>)( boolean useEmojiAsDefaultStyle, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Integer.html> emojiAsDefaultStyleExceptions )` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#unregisterInitCallback(androidx.emoji2.text.EmojiCompat.InitCallback)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.InitCallback initCallback)` Unregisters a callback that was added before. |

| ### Protected methods |
|---|---|
| `final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.MetadataRepoLoader` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#getMetadataRepoLoader()()` Returns the `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.MetadataRepoLoader`. |

## Protected constructors

### Config

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

```
protected Config(@NonNull EmojiCompat.MetadataRepoLoader metadataLoader)
```

Default constructor.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.MetadataRepoLoader metadataLoader` | MetadataRepoLoader instance, cannot be `null` |

## Public methods

### registerInitCallback

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

```
public @NonNull EmojiCompat.Config registerInitCallback(@NonNull EmojiCompat.InitCallback initCallback)
```

Registers an initialization callback.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.InitCallback initCallback` | the initialization callback to register, cannot be `null` |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | EmojiCompat.Config instance |

### registerInitCallback

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

```
public @NonNull EmojiCompat.Config registerInitCallback(
    @NonNull Executor executor,
    @NonNull EmojiCompat.InitCallback initCallback
)
```

Registers an initialization callback.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | executor to dispatch callback on |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.InitCallback initCallback` | the initialization callback to register, cannot be `null` |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | EmojiCompat.Config instance |

### setEmojiSpanIndicatorColor

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

```
public @NonNull EmojiCompat.Config setEmojiSpanIndicatorColor(@ColorInt int color)
```

Sets the color used as emoji span indicator. The default value is `https://developer.android.com/reference/android/graphics/Color.html#GREEN`.

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

### setEmojiSpanIndicatorEnabled

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

```
public @NonNull EmojiCompat.Config setEmojiSpanIndicatorEnabled(boolean emojiSpanIndicatorEnabled)
```

Determines whether a background will be drawn for the emojis that are found and replaced by EmojiCompat. Should be used only for debugging purposes. The indicator color can be set using `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setEmojiSpanIndicatorColor(int)`.

| Parameters |
|---|---|
| `boolean emojiSpanIndicatorEnabled` | when `true` a background is drawn for each emoji that is replaced |

### setGlyphChecker

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

```
public @NonNull EmojiCompat.Config setGlyphChecker(@NonNull EmojiCompat.GlyphChecker glyphChecker)
```

The interface that is used by EmojiCompat in order to check if a given emoji can be rendered by the system.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.GlyphChecker glyphChecker` | `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.GlyphChecker` instance to be used. |

### setMetadataLoadStrategy

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

```
public @NonNull EmojiCompat.Config setMetadataLoadStrategy(int strategy)
```

Determines the strategy to start loading the metadata. By default `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat` will start loading the metadata during `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#init(androidx.emoji2.text.EmojiCompat.Config)`. When set to `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#LOAD_STRATEGY_MANUAL()`, you should call `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#load()` to initiate metadata loading.
Default implementations of `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.MetadataRepoLoader` start a thread during their `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.MetadataRepoLoader#load(androidx.emoji2.text.EmojiCompat.MetadataRepoLoaderCallback)` functions. Just instantiating and starting a thread might take time especially in older devices. Since `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#init(androidx.emoji2.text.EmojiCompat.Config)` has to be called before any EmojiCompat widgets are inflated, this results in time spent either on your Application.onCreate or Activity .onCreate. If you'd like to gain more control on when to start loading the metadata and be able to call `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#init(androidx.emoji2.text.EmojiCompat.Config)` with absolute minimum time cost you can use `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#LOAD_STRATEGY_MANUAL()`. When set to `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#LOAD_STRATEGY_MANUAL()`, `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat` will wait for `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#load()` to be called by the developer in order to start loading metadata, therefore you should call `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#load()` to initiate metadata loading. `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#load()` can be called from any thread.

```
EmojiCompat.Config config = new FontRequestEmojiCompatConfig(context, fontRequest)
        .setMetadataLoadStrategy(EmojiCompat.LOAD_STRATEGY_MANUAL);

// EmojiCompat will not start loading metadata and MetadataRepoLoader#load(...)
// will not be called
EmojiCompat.init(config);

// At any time (i.e. idle time or executorService is ready)
// call EmojiCompat#load() to start loading metadata.
executorService.execute(() -> EmojiCompat.get().load());
```

| Parameters |
|---|---|
| `int strategy` | one of `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#LOAD_STRATEGY_DEFAULT()`, `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat#LOAD_STRATEGY_MANUAL()` |

### setReplaceAll

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

```
public @NonNull EmojiCompat.Config setReplaceAll(boolean replaceAll)
```

Determines whether EmojiCompat should replace all the emojis it finds with the EmojiSpans. By default EmojiCompat tries its best to understand if the system already can render an emoji and do not replace those emojis.

| Parameters |
|---|---|
| `boolean replaceAll` | replace all emojis found with EmojiSpans |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | EmojiCompat.Config instance |

### setSpanFactory

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

```
public @NonNull EmojiCompat.Config setSpanFactory(@NonNull EmojiCompat.SpanFactory factory)
```

Set the span factory used to actually draw emoji replacements.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.SpanFactory factory` | custum span factory that can draw the emoji replacements |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | this |

### setUseAfterUpdatableSystemFonts

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

```
public @NonNull EmojiCompat.Config setUseAfterUpdatableSystemFonts(boolean useAfter)
```

Configure whether EmojiCompat should continue to process emojis and load metadata on devices that support Updatable System Fonts (API 35 and above).

While Updatable System Fonts was introduced in API 31, it was not enabled on 100% of devices until API 35. Therefore, EmojiCompat treats API 35 and above as having guaranteed updatable system fonts.

When set to `false` (the default), EmojiCompat initialization and processing will become no-ops on API 35 and above. This can reduce application startup latency and memory usage by avoiding loading the EmojiCompat font when the system font is already up-to-date.

When set to `true`, EmojiCompat will continue to load metadata and process emojis on API 35 and above.

| Parameters |
|---|---|
| `boolean useAfter` | `true` to use EmojiCompat on API 35 and above; `false` to disable it. Defaults to `false`. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | EmojiCompat.Config instance |

### setUseEmojiAsDefaultStyle

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

```
public @NonNull EmojiCompat.Config setUseEmojiAsDefaultStyle(boolean useEmojiAsDefaultStyle)
```

Determines whether EmojiCompat should use the emoji presentation style for emojis that have text style as default. By default, the text style would be used, unless these are followed by the U+FE0F variation selector. Details about emoji presentation and text presentation styles can be found here: http://unicode.org/reports/tr51/#Presentation_Style If useEmojiAsDefaultStyle is true, the emoji presentation style will be used for all emojis, including potentially unexpected ones (such as digits or other keycap emojis). If this is not the expected behaviour, method `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setUseEmojiAsDefaultStyle(boolean,java.util.List<java.lang.Integer>)` can be used to specify the exception emojis that should be still presented as text style.

| Parameters |
|---|---|
| `boolean useEmojiAsDefaultStyle` | whether to use the emoji style presentation for all emojis that would be presented as text style by default |

### setUseEmojiAsDefaultStyle

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

```
public @NonNull EmojiCompat.Config setUseEmojiAsDefaultStyle(
    boolean useEmojiAsDefaultStyle,
    @Nullable List<Integer> emojiAsDefaultStyleExceptions
)
```

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Integer.html> emojiAsDefaultStyleExceptions` | Contains the exception emojis which will be still presented as text style even if the useEmojiAsDefaultStyle flag is set to `true`. This list will be ignored if useEmojiAsDefaultStyle is `false`. Note that emojis with default emoji style presentation will remain emoji style regardless the value of useEmojiAsDefaultStyle or whether they are included in the exceptions list or not. When no exception is wanted, the method `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config#setUseEmojiAsDefaultStyle(boolean)` should be used instead. |

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

### unregisterInitCallback

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

```
public @NonNull EmojiCompat.Config unregisterInitCallback(@NonNull EmojiCompat.InitCallback initCallback)
```

Unregisters a callback that was added before.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.InitCallback initCallback` | the initialization callback to be removed, cannot be `null` |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.Config` | EmojiCompat.Config instance |

## Protected methods

### getMetadataRepoLoader

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

```
protected final @NonNull EmojiCompat.MetadataRepoLoader getMetadataRepoLoader()
```

Returns the `https://developer.android.com/reference/androidx/emoji2/text/EmojiCompat.MetadataRepoLoader`.