这两天在做 android 友盟 用户反馈 自定义界面发图片,官方文档里面 没有发图片的示列代码,经过对jar 还有simple工程多翻探查,发现一方法可用 conversation.addUserReply("", replyMsg, "image_reply", -1.0F);
private FeedbackAgent agent;
private Conversation conversation;
agent = new FeedbackAgent(this);
private void syncFeedbackUserInfo() {
UserInfo info = agent.getUserInfo();
if (info == null)
info = new UserInfo();
Map<String, String> contact = info.getContact();
if (contact == null)
contact = new HashMap<String, String>();
StringBuilder contact_info = new StringBuilder();
contact_info.append(ckq1 ? checkTextQ1.getText().toString() + "," : "");
contact_info.append(ckq2 ? checkTextQ2.getText().toString() + "," : "");
contact_info.append(ckq3 ? checkTextQ3.getText().toString() + "," : "");
contact_info.append(ckq4 ? checkTextQ4.getText().toString() + "," : "");
contact_info.append(ckq5 ? checkTextQ5.getText().toString() + "," : "");
contact_info.append(ckq6 ? checkTextQ6.getText().toString() + "," : "");
contact_info.append(ckq7 ? checkTextQ7.getText().toString() + "," : "");
contact_info.append(ckq8 ? checkTextQ8.getText().toString() + "," : "");
String otherq = other_problem_eidt.getText().toString().trim();
contact_info.append(otherq);
String contactstr = contacts_edit.getText().toString().trim();
if (contact_info.toString().equals("") && contactstr.equals("")) {
ShowMessage.TostMsg("请选择或写下您要反馈的问题");
return;
}
if (isMobileNO(contactstr)) {
contact.put("phone", contactstr);
} else if (isEmail(contactstr)) {
contact.put("email", contactstr);
} else if (isQQ(contactstr)) {
contact.put("qq", contactstr);
} else if (contactstr.isEmpty()) {
ShowMessage.TostMsg("请留下您的联系方式");
return;
} else {
ShowMessage.TostMsg("请留下您正确的联系方式");
return;
}
//判断网络
if (!NetWork.isNetworkAvailable(this)) {
ShowMessage.TostMsg("当前网络异常无法提交");
return;
}
info.setContact(contact);
agent.setUserInfo(info);
conversation = agent.getDefaultConversation();
if (thumBean != null && thumBean.getmPhotoUri() != null) {
sendMsgToDev(contact_info.toString(), Reply.CONTENT_TYPE_TEXT_REPLY);// 用户反馈意见
if (UMengB.a(FeedbackActivity.this, thumBean.getmPhotoUri())) {
UMengB.a(FeedbackActivity.this, thumBean.getmPhotoUri(), "R" + UUID.randomUUID().toString(), new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
sendMsgToDev((String) msg.obj, Reply.CONTENT_TYPE_IMAGE_REPLY);
}
});
}
} else {
sendMsgToDev(contact_info.toString(), Reply.CONTENT_TYPE_TEXT_REPLY);// 用户反馈意见
}
}
/**
* 用户发送了一条新的信息后调用此方法
*
* @param replyMsg 信息的内容
* @param type Reply.CONTENT_TYPE_TEXT_REPLY或者Reply.CONTENT_TYPE_IMAGE_REPLY
*/
public void sendMsgToDev(String replyMsg, String type) {
if (type.equals(Reply.CONTENT_TYPE_TEXT_REPLY)) {
conversation.addUserReply(replyMsg);
} else if (type.equals(Reply.CONTENT_TYPE_IMAGE_REPLY)) {
conversation.addUserReply("", replyMsg, "image_reply", -1.0F);
}
conversation.sync(this);
new Thread(new Runnable() {
@Override
public void run() {
agent.updateUserInfo();
}
}).start();
}