I have a chat app which I want to extend with emoticons.
This code is used to insert a smilie in the text:
Spanned cs = Html.fromHtml("<img src ='"+ index +"'/>", imageGetter, null);
int cursorPosition = content.getSelectionStart();
content.getText().insert(cursorPosition, cs);
This is working great. The smilies show up in the textView at the right place.
Now I want to send the text to my server via HTTP. I would like to store ":)" instead of the image as for ones using an older app version the image can not be displayed. In the new version I convert ":)" to the image before displaying the text. Is there any way to convert the image to a specific string?
if you want to replace your emoticons try this:
here if
fastReplace == true
you don't have to scan the whole text but it's only minimal implementation: works only if you type ")" right after typed ":", iffastReplace == false
it replaces every occurrence of ":)" with a smiley but it has to scan the whole text so it's a bit slower when text is quite large