This is a late answer but I recently ran into a similar problem. I needed to filter through a List<String>
and filter out emojis that couldn't be rendered on the device (i.e., if the device was old and didn't support rendering them).
What I ended up doing was using Paint
to measure the text width.
Paint mPaint = new Paint();
private boolean emojiRenderable(String emoji) {
float width = mPaint.measureText(emoji);
if (width > 7) return true;
return false;
}
The width > 7
part is particularly hacky, I would expect the value to be 0.0
for non-renderable emoji, but across a few devices, I found that the value actually ranged around 3.0
to 6.0
for non-renderable, and 12.0
to 15.0
for renderable. Your results may vary so you might want to test that. I believe the font size also has an effect on the output of measureText()
so keep that in mind.
Overall I am not sure if this is a great solution but it's the best that I've come up with so far.
<img src='...' />
and use HTML.fomHTML. Quite an overkill. – Brigittebriley