Skip to content
Branch: master
Find file History

Android EmojiCompat Sample (Kotlin)

This sample demonstrates usage of EmojiCompat support library. You can use this library to prevent your app from showing missing emoji characters in the form of tofu (□). You can use either bundled or downloadable emoji fonts. This sample shows both usages.


The EmojiCompat support library aims to keep Android devices up to date with the latest emoji. It prevents your app from showing missing emoji characters in the form of ☐, which indicates that your device does not have a font to display the text. By using the EmojiCompat support library, your app users do not need to wait for Android OS updates to get the latest emoji.

For further detail, read Emoji Compatibility documentation.


You need to first initialize EmojiCompat to load the metadata and the typeface. You can use either bundled or downloadable fonts.

Use downloadable fonts

You need the beta version of Google Play Services to use this feature. Join Google Play Services Public Beta Program and make sure you have v11 installed on your device running Android O Developer Preview 2.

For the downloadable font configuration, you need to create an instance of the FontRequest class, and provide the font provider authority, the font provider package, the font query, and a list of set of hashes for the certificates. For more information about FontRequest, refer to the Downloadable Fonts documentation. You can then create an instance of FontRequestEmojiCompatConfig and pass it to EmojiCompat.init().

final FontRequest fontRequest = new FontRequest(
                    "Noto Color Emoji Compat",
EmojiCompat.init(new FontRequestEmojiCompatConfig(getApplicationContext(), fontRequest)
                    .registerInitCallback(new EmojiCompat.InitCallback() {
                        public void onInitialized() {
                            Log.i(TAG, "EmojiCompat initialized");

                        public void onFailed(@Nullable Throwable throwable) {
                            Log.e(TAG, "EmojiCompat initialization failed", throwable);

Use bundled font

In order the use the bundled font, call init() method of EmojiCompat with an instance of BundledEmojiCompatConfig.

Use EmojiCompat

Built-in views

The easiest way to use EmojiCompat in your layout, is to use EmojiAppCompatTextView, EmojiAppCompatEditText, or EmojiAppCompatButton. You can use them in your layout XMLs or code. You can just set any text containing emoji and the widgets handle the rest.

With regular TextViews

If you want to use EmojiCompat with a regular TextView, retrieve an instance of EmojiCompat by calling EmojiCompat.get() and call registerInitCallback method. You can pass an EmojiCompat.InitCallback and use the EmojiCompat#process() method there to transform emoji text into a backward-compatible format.

With custom TextViews

If you want to use EmojiCompat in your custom TextView, you can create an instance of EmojiTextViewHelper and use it in some overridden methods, namely setFilters and setAllCaps. shows what to do inside them.


  • Android SDK 25
  • Android Build Tools v25.0.3
  • Android Support Repository



Getting Started

This sample uses the Gradle build system. To build this project, use the "gradlew build" command or use "Import Project" in Android Studio.


If you've found an error in this sample, please file an issue:

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub. Please see for more details.

You can’t perform that action at this time.