private void refreshLike(String like) { if (like != null) { try { JSONObject jsonObject = new JSONObject(like); String state = jsonObject.getString(JsonString.Return.STATE); if (state.equals("20002")) { // 对方已经Like过我 ToastUtil.prompt(this, "双方相互Like,你们已经是好友了"); Intent intent = new Intent(IntentString.Receiver.NEW_FRIEND); sendBroadcast(intent); EMMessage message = EMMessage.createSendMessage(EMMessage.Type.TXT); TextMessageBody txtBody = new TextMessageBody("我们已经是好友了,可以开始聊天了"); message.addBody(txtBody); message.setReceipt(person.getId()); EMConversation conversation = EMChatManager.getInstance().getConversation(person.getId()); conversation.addMessage(message); finish(); } else if (state.equals("10004")) { ToastUtil.longPrompt(this, "检测到您的头像不是真人头像,Like操作无效"); } else { ToastUtil.prompt(this, "Like操作失败!"); } } catch (JSONException e) { e.printStackTrace(); } } else { ToastUtil.noNet(this); } }
/** * 保存通话消息记录 * * @param type 0:音频,1:视频 */ protected void saveCallRecord(int type) { EMMessage message = null; TextMessageBody txtBody = null; if (!isInComingCall) { // 打出去的通话 message = EMMessage.createSendMessage(EMMessage.Type.TXT); message.setReceipt(username); } else { message = EMMessage.createReceiveMessage(EMMessage.Type.TXT); message.setFrom(username); } String st1 = getResources().getString(R.string.call_duration); String st2 = getResources().getString(R.string.Refused); String st3 = getResources().getString(R.string.The_other_party_has_refused_to); String st4 = getResources().getString(R.string.The_other_is_not_online); String st5 = getResources().getString(R.string.The_other_is_on_the_phone); String st6 = getResources().getString(R.string.The_other_party_did_not_answer); String st7 = getResources().getString(R.string.did_not_answer); String st8 = getResources().getString(R.string.Has_been_cancelled); switch (callingState) { case NORMAL: txtBody = new TextMessageBody(st1 + callDruationText); break; case REFUESD: txtBody = new TextMessageBody(st2); break; case BEREFUESD: txtBody = new TextMessageBody(st3); break; case OFFLINE: txtBody = new TextMessageBody(st4); break; case BUSY: txtBody = new TextMessageBody(st5); break; case NORESPONSE: txtBody = new TextMessageBody(st6); break; case UNANSWERED: txtBody = new TextMessageBody(st7); break; default: txtBody = new TextMessageBody(st8); break; } // 设置扩展属性 if (type == 0) message.setAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, true); else message.setAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, true); // 设置消息body message.addBody(txtBody); message.setMsgId(msgid); // 保存 EMChatManager.getInstance().saveMessage(message, false); }
public static void EaseBlackUser(String action, String easeName) { EMMessage cmdMsg = EMMessage.createSendMessage(EMMessage.Type.CMD); CmdMessageBody cmdBody = new CmdMessageBody(action); cmdMsg.setReceipt(easeName); cmdMsg.addBody(cmdBody); EMChatManager.getInstance() .sendMessage( cmdMsg, new EMCallBack() { @Override public void onSuccess() { Log.e("发送请求视频的透传发送成功", ""); } @Override public void onError(int i, String s) { Log.e("发送请求视频的透传发送失败", ""); } @Override public void onProgress(int i, String s) {} }); }