Android的聊天应用程序中的表情符号的问题 [英] Android chat application emoji's issue

查看:121
本文介绍了Android的聊天应用程序中的表情符号的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作在Android聊天应用程序。现在,我想送的表情符号在我的聊天模块。我怎样才能在聊天应用程序实现的表情符号?请指导我为这个应用程序。如果没有为这个应用程序的任何API随后还建议我。谢谢

 公共无效callAsynchronousTask(){
    最后的处理程序处理程序=新的处理程序();
    定时器=新定时器();
    TimerTask的doAsynchronousTask =新的TimerTask(){
        @覆盖
        公共无效的run(){
            handler.post(新的Runnable(){
                公共无效的run(){
                    尝试{
                        新GetSingleChat(Chat_Detail_Single.this).execute(friend_id);                    }赶上(NullPointerException异常五){                    }
                }
            });        }
    };
    timer.schedule(doAsynchronousTask,1000,1000);}@覆盖
公共无效的onClick(视图v){    开关(v.getId()){
        案例R.id.btncamera:
            Dialog_Manager.chooseImage(Chat_Detail_Single.thissinglechat);
            打破;
        案例R.id.img_back:
            timer.cancel();
            完();
            打破;
        案例R.id.btnsend:
            。字符串消息_ ​​= edt_mes.getText()的toString();
            如果(message_.replace(,)。长度()== 0){            }其他{
                edt_mes.setText();
                新Send_chat_message(Chat_Detail_Single.this).execute(共享pref.getUserID(本),friend_id,MES,消息_);            }
            打破;    }
}
      公共静态无效get_chat_data(列表< Chat_prop> fetch_chat){
    MyCustomList.clear();
    MyCustomList.addAll(fetch_chat);    尝试{
        如果(adptor == NULL){            adptor =新Single_Chat_Adap(活动,
                    MyCustomList);
            Chat_Detail_Single.listView.setAdapter(adptor);
            Chat_Detail_Single.listView.setSelection(MyCustomList
                    .size() - 1);
            lastCount = MyCustomList.size();
        }其他{            如果(lastCount!= MyCustomList.size()){
                lastCount = MyCustomList.size();
                adptor.notifyDataSetChanged();
                Chat_Detail_Single.listView
                        .setSelection(MyCustomList.size());            }
        }
    }赶上(NullPointerException异常五){    }赶上(例外五){
        // TODO:处理异常
    }}
       @覆盖
保护无效的onActivityResult(INT申请code,INT结果code,意图数据){
    super.onActivityResult(要求code,结果code,数据);    尝试{        如果(要求code == Dialog_Manager.Gallery_Intent
                &功放;&安培;结果code == RESULT_OK&放大器;&安培;数据!= NULL){            文件直接=新的文件(
                    Environment.getExternalStorageDirectory()+/乐趣,你);
            如果(!direct.exists()){
                如果(direct.mkdir())
                    ;
            }
            很长一段时间= System.currentTimeMillis的();
            capturepath1 = direct.getAbsolutePath()+/+时间+.JPG;
            档案文件=新的文件(capturepath1);
            乌里outputFileUri = Uri.fromFile(文件);
            乌里selectedImage = data.getData();
            的ImagePath =的getPath(selectedImage);
            意图cropIntent =新意图(com.android.camera.action.CROP);
            乌里contentUri = selectedImage;
            cropIntent.setDataAndType(contentUri,图像/ *);
            cropIntent.putExtra(裁剪,真);
            cropIntent.putExtra(aspectX,1);
            cropIntent.putExtra(aspectY,1);
            cropIntent.putExtra(outputX,1000);
            cropIntent.putExtra(outputY,1000);
            cropIntent.putExtra(MediaStore.EXTRA_OUTPUT,outputFileUri);
            cropIntent.putExtra(回归数据,真正的);
            startActivityForResult(cropIntent,3);        }否则如果(要求code == Dialog_Manager.Camera_Intent
                &功放;&安培;结果code == RESULT_OK){            文件直接=新的文件(
                    Environment.getExternalStorageDirectory()+/乐趣,你);
            如果(!direct.exists()){
                如果(direct.mkdir())
                    ;
            }
            很长一段时间= System.currentTimeMillis的();
            capturepath1 = direct.getAbsolutePath()+/+时间+.JPG;
            档案文件=新的文件(capturepath1);
            乌里outputFileUri = Uri.fromFile(文件);
            文件照片=新的文件(的ImagePath);
            乌里selectedImage = Uri.fromFile(照片);
            意图cropIntent =新意图(com.android.camera.action.CROP);
            乌里contentUri = selectedImage;
            cropIntent.setDataAndType(contentUri,图像/ *);
            cropIntent.putExtra(裁剪,真);
            cropIntent.putExtra(aspectX,1);
            cropIntent.putExtra(aspectY,1);
            cropIntent.putExtra(outputX,1000);
            cropIntent.putExtra(outputY,1000);
            cropIntent.putExtra(MediaStore.EXTRA_OUTPUT,outputFileUri);
            cropIntent.putExtra(回归数据,真正的);
            startActivityForResult(cropIntent,3);        }否则如果(要求code == 3){
            尝试{
                位图的缩略图= NULL;
                捆绑额外= data.getExtras();
                如果(临时演员!= NULL){
                    缩略图= extras.getParcelable(数据);
                    位图BM =缩略图;
                    BM = ExtraMethods.de codeFILE(capturepath1);
                    BM = ExifUtils.rotateBitmap(capturepath1,BM);
                    //新Uplaod_image()执行(capturepath1)。
                    新Send_chat_message(Chat_Detail_Single.this).execute(共享pref.getUserID(本),friend_id,形象,capturepath1);
                }            }赶上(例外五){
                e.printStackTrace();
            }
        }
    }赶上(例外五){
        Toast.makeText(getApplicationContext(),E +,Toast.LENGTH_LONG)
                。显示();
    }}
 公共字符串的getPath(URI URI){
    如果(URI == NULL){
        返回null;
    }
    的String [] =投影{MediaStore.Images.Media.DATA};
    光标光标= getContentResolver()查询(URI,投影,NULL,NULL,
            空值);
    如果(指针!= NULL){
        INT与Column_Index =光标
                .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        返回cursor.getString(Column_Index中);
    }
    返回uri.getPath();
}


解决方案

这个库是你所需要的实施 Emojicons 。只是不要忘记你的的TextView 的EditText s到改变这图书馆的 EmojiconTextView EmojiconEditText S表示。

希望这有助于。

I am working on Android chat application. Now I want to send emoji's in my chat module. How can i implement emoji' in chat application? Please guide me for this app. If there is any API for this app then also suggest me. Thanks

  public void callAsynchronousTask() {
    final Handler handler = new Handler();
    timer = new Timer();
    TimerTask doAsynchronousTask = new TimerTask() {
        @Override
        public void run() {
            handler.post(new Runnable() {
                public void run() {
                    try {
                        new GetSingleChat(Chat_Detail_Single.this).execute(friend_id);

                    } catch (NullPointerException e) {

                    }
                }
            });

        }
    };
    timer.schedule(doAsynchronousTask, 1000, 1000);

} 

@Override
public void onClick(View v) {

    switch (v.getId()) {
        case R.id.btncamera:
            Dialog_Manager.chooseImage(Chat_Detail_Single.this, "singlechat");
            break;
        case R.id.img_back:
            timer.cancel();
            finish();
            break;
        case R.id.btnsend:
            String message_ = edt_mes.getText().toString();
            if (message_.replace(" ", "").length() == 0) {

            } else {
                edt_mes.setText("");
                new  Send_chat_message(Chat_Detail_Single.this).execute(SharedPref.getUserID(this), friend_id, "mes", message_);

            }
            break;

    }
} 
      public static void get_chat_data(List<Chat_prop> fetch_chat) {
    MyCustomList.clear();
    MyCustomList.addAll(fetch_chat);

    try {
        if (adptor == null) {

            adptor = new Single_Chat_Adap(activity,
                    MyCustomList);
            Chat_Detail_Single.listView.setAdapter(adptor);
            Chat_Detail_Single.listView.setSelection(MyCustomList
                    .size() - 1);
            lastCount = MyCustomList.size();
        } else {

            if (lastCount != MyCustomList.size()) {
                lastCount = MyCustomList.size();
                adptor.notifyDataSetChanged();
                Chat_Detail_Single.listView
                        .setSelection(MyCustomList.size());

            }


        }
    } catch (NullPointerException e) {

    } catch (Exception e) {
        // TODO: handle exception
    }

}
       @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    try {

        if (requestCode == Dialog_Manager.Gallery_Intent
                && resultCode == RESULT_OK && data != null) {

            File direct = new File(
                    Environment.getExternalStorageDirectory() + "/Fun You");
            if (!direct.exists()) {
                if (direct.mkdir())
                    ;
            }
            long time = System.currentTimeMillis();
            capturepath1 = direct.getAbsolutePath() + "/" + time + ".jpg";
            File file = new File(capturepath1);
            Uri outputFileUri = Uri.fromFile(file);
            Uri selectedImage = data.getData();
            imagePath = getPath(selectedImage);
            Intent cropIntent = new Intent("com.android.camera.action.CROP");
            Uri contentUri = selectedImage;
            cropIntent.setDataAndType(contentUri, "image/*");
            cropIntent.putExtra("crop", "true");
            cropIntent.putExtra("aspectX", 1);
            cropIntent.putExtra("aspectY", 1);
            cropIntent.putExtra("outputX", 1000);
            cropIntent.putExtra("outputY", 1000);
            cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            cropIntent.putExtra("return-data", true);
            startActivityForResult(cropIntent, 3);

        } else if (requestCode == Dialog_Manager.Camera_Intent
                && resultCode == RESULT_OK) {

            File direct = new File(
                    Environment.getExternalStorageDirectory() + "/Fun You");
            if (!direct.exists()) {
                if (direct.mkdir())
                    ;
            }
            long time = System.currentTimeMillis();
            capturepath1 = direct.getAbsolutePath() + "/" + time + ".jpg";
            File file = new File(capturepath1);
            Uri outputFileUri = Uri.fromFile(file);
            File photos = new File(imagePath);
            Uri selectedImage = Uri.fromFile(photos);
            Intent cropIntent = new Intent("com.android.camera.action.CROP");
            Uri contentUri = selectedImage;
            cropIntent.setDataAndType(contentUri, "image/*");
            cropIntent.putExtra("crop", "true");
            cropIntent.putExtra("aspectX", 1);
            cropIntent.putExtra("aspectY", 1);
            cropIntent.putExtra("outputX", 1000);
            cropIntent.putExtra("outputY", 1000);
            cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            cropIntent.putExtra("return-data", true);
            startActivityForResult(cropIntent, 3);

        } else if (requestCode == 3) {
            try {
                Bitmap thumbnail = null;
                Bundle extras = data.getExtras();
                if (extras != null) {
                    thumbnail = extras.getParcelable("data");
                    Bitmap bm = thumbnail;
                    bm = ExtraMethods.decodeFile(capturepath1);
                    bm = ExifUtils.rotateBitmap(capturepath1, bm);
                    // new Uplaod_image().execute(capturepath1);
                    new Send_chat_message(Chat_Detail_Single.this).execute(SharedPref.getUserID(this), friend_id, "image", capturepath1);
                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } catch (Exception e) {
        Toast.makeText(getApplicationContext(), e + "", Toast.LENGTH_LONG)
                .show();
    }

}
 public String getPath(Uri uri) {
    if (uri == null) {
        return null;
    }
    String[] projection = {MediaStore.Images.Media.DATA};
    Cursor cursor = getContentResolver().query(uri, projection, null, null,
            null);
    if (cursor != null) {
        int column_index = cursor
                .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        return cursor.getString(column_index);
    }
    return uri.getPath();
}

解决方案

This Library is all you need to implement Emojicons. Just don't forget to change your TextViews and EditTexts to this Library's EmojiconTextViews and EmojiconEditTexts respectively.

Hope this helps.

这篇关于Android的聊天应用程序中的表情符号的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆