Neeraj Mehta
Neeraj Mehta

Reputation: 1705

Unable to see default android emoji in textview of my android app

I am developing a text messaging android app and when I am sending a text message with android keyboard emoji and recieving in another android mobile it is showing ?? (double Question mark). How can I able to see that emoji in my textview?

Like as below I am appending that text message

holder.chatText.setText(tempValues.getMessageText()+" \n ");

and sending that message to server as below

 public class SyncPendingMessageToServer extends AsyncTask<String, Void, Boolean> {
    protected void onPreExecute() {
        //doShowLoading("Please Wait");
    }

    protected Boolean doInBackground(String... params) {
        if(Config.isInternetOn(getApplicationContext())  && loginUserInfoId == "") {
            List<ChatMessage> allChatMessage = db.getAllMessage();
            for (ChatMessage chatMessage : allChatMessage) {

                if (chatMessage.getIsPending() == 1 && chatMessage.getMediaMIMEType().isEmpty()) {
                    String msgText = chatMessage.getMessageText();

                    HttpClient myClient = new DefaultHttpClient();
                    HttpPost myConnection = new HttpPost(Config.HOST_NAME + "/AndroidApp/SendMessage");

                    try {
                        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                        nameValuePairs.add(new BasicNameValuePair("messageText", msgText));
                        nameValuePairs.add(new BasicNameValuePair("senderUserInfoId", chatMessage.getSenderUserInfoId()));
                        nameValuePairs.add(new BasicNameValuePair("recieverUserInfoId", chatMessage.getReceiverUserInfoId()));
                        nameValuePairs.add(new BasicNameValuePair("messageThreadId", chatMessage.getOriginalMsgThreadId()));
                        nameValuePairs.add(new BasicNameValuePair("url", ""));
                        nameValuePairs.add(new BasicNameValuePair("fileType", ""));

                        if(chatMessage.getIsPendingToUpdate() == 0) {
                            nameValuePairs.add(new BasicNameValuePair("msgType", ""));
                        }
                        if(chatMessage.getIsPendingToUpdate() == 1) {
                            nameValuePairs.add(new BasicNameValuePair("msgType", "GROUP"));
                        }

                        myConnection.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                        myClient.execute(myConnection);

                    } catch (ClientProtocolException e) {
                        Toast.makeText(getApplicationContext(), "Message sending Failed!", Toast.LENGTH_LONG).show();
                        //e.printStackTrace();
                    } catch (IOException e) {
                        //e.printStackTrace();
                    }
                }
            }
            db.updateSyncedMessage();
        }
        return true;
    }

    protected void onPostExecute(Boolean status) {
        //do whatever you want in this method
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                new SyncPendingMessageToServer().execute();
            }
        }, 200);
    }
}

Upvotes: 1

Views: 1195

Answers (2)

aga
aga

Reputation: 29434

Android has support of emoji starting from 4.4. Some vendors built-in emoji in previous versions of Android, but you can't rely on it.
The best choice would be to use some library which allows to show emoji in text views, emojicon is one of them.

Upvotes: 1

Charaf Eddine Mechalikh
Charaf Eddine Mechalikh

Reputation: 1248

this is a good openSource for you https://github.com/rockerhieu/emojicon hope it helps..it allows you to display smileys in textView

Upvotes: 0

Related Questions