Posts

Showing posts from April, 2019

How to share text to WhatsApp from my app in Android Programetically?

Intent whatsappIntent = new Intent ( Intent . ACTION_SEND ); whatsappIntent . setType ( "text/plain" ); whatsappIntent . setPackage ( "com.whatsapp" ); whatsappIntent . putExtra ( Intent . EXTRA_TEXT , "The text you wanted to share" ); try { activity . startActivity ( whatsappIntent ); } catch ( android . content . ActivityNotFoundException ex ) { ToastHelper . MakeShortText ( "Whatsapp have not been installed." ); }

how to encode and decode emoji in android?

We can use commons-lang(commons-lang-2.5.jar) library for encoding and decoding of the unicode characters.  use  gradle:  implementation 'org.apache.commons:commons-lang3:3.4' . For Encoding use  -  StringEscapeUtils.escapeJava(String text)  This can be used in android  EditText  when call  getText  method, where it will encode the unicode characters properly before sending to web server. For Decoding use  -  StringEscapeUtils.unescapeJava(String text)  This can be used in android  TextView  to  setText , where it will decode the unicode characters properly after receiving the response from web server. Ex: EditText etEmojiEditText = new EditText ( this ); etEmojiEditText . setText ( "TYPE SOMETHING IN EMOJI" ); String toServer = etEmojiEditText . getText (); String toServerUnicodeEncoded = StringEscapeUtils . escapeJava ( toServer ); String serverResponse = "SOME RESPONSE FROM S...