Reputation: 7358
For supporting Emojis
in our app, we are using Downloadable fonts as mentioned in the following guide. We are using Emoji Support Library version 26.0.0
. The code for init of the library is as follows.
private void initEmoji() {
final FontRequest fontRequest = new FontRequest(
"com.google.android.gms.fonts",
"com.google.android.gms",
"Noto Color Emoji Compat",
R.array.com_google_android_gms_fonts_certs);
EmojiCompat.Config config = new
FontRequestEmojiCompatConfig(getApplicationContext(), fontRequest)
.setReplaceAll(true)
.registerInitCallback(new EmojiCompat.InitCallback() {
@Override
public void onInitialized() {
Log.i(NewsHuntAppController.class.getSimpleName(), "EmojiCompat initialized");
}
@Override
public void onFailed(@Nullable Throwable throwable) {
Log.e(NewsHuntAppController.class.getSimpleName(), "EmojiCompat initialization failed",
throwable);
}
});
EmojiCompat.init(config);
}
We tested the emojis on two devices. The first device is Android KitKat and the second device is an Android Nougat device. Both of these devices have the same google play services version. We observed that most of the Emojis are rendering same on both the devices, but there are few Emojis which are loading on Android Nougat, but not on Android KitKat.
Following are the sample Emojis, which are not loading on Android KitKat.
🖱🖥🖲🖨🕹🗜
Ideally, if both the devices are having same google play services version, then the emojis should be rendered on both the devices. But this is not happening. If anyone knows the reason for this, then please let know.
Upvotes: 1
Views: 1405
Reputation: 525
So, based on the answer from @Siyamed, the solution is add U+FE0F anyway.
The Code looks like this:
private static int[] fix(int... ary) {
if (ary[ary.length - 1] == 0xfe0f) return ary;
int[] result = Arrays.copyOf(ary, ary.length + 1);
result[ary.length] = 0xfe0f;
return result;
}
...
int[] codePoints = fix(0x1f1fe, 0x1f1ea); // <- just a example, I added it to all emojis
String emoji = new String(codePoints, 0, codePoints.length);
Upvotes: 0
Reputation: 515
With the newest version of support library developer has control over if EmojiCompat will render without variation selector, and exceptions to that rule. please refer to: https://developer.android.com/reference/android/support/text/emoji/EmojiCompat.Config.html#setUseEmojiAsDefaultStyle(boolean)
🖥 (https://emojipedia.org/emoji/%F0%9F%96%A5/) is an emoji which is "text presentation" by default. this means when only U+1F5A5 exists standard says it is suggested to render it in text presentation (kind of symbol).
That's why EmojiCompat does not accept it as an emoji. Currently for EmojiCompat to accept it as an emoji you will have to use that specific codepoint with Emoji Variation Selector(U+FE0F). i.e U+1F5A5 U+FE0F
Upvotes: 1