有同時通過XMPP.Below發送圖像,我面對的是代碼的問題片段,我都做。我不知道代碼有什麼問題。新建信息,同時通過Asmack
Message msg = new Message(emailId, Message.Type.chat);
ImageTransferExtension transfer = new ImageTransferExtension();
transfer.setImageName(mImageUri.getEncodedPath());
transfer.setUserRecipient(emailId);
msg.addExtension(transfer);
這裏是ImagesTransferExtension代碼片斷
編輯:
public class ImageTransferExtension implements PacketExtension {
private String userRecipient;
private String ftpUrl;
private String httpUrl;
private String id;
private String typeOfMessage;
private String fieldName;
private String duration;
@Override
public String getElementName() {
// TODO Auto-generated method stub
return "x";
}
@Override
public String getNamespace() {
// TODO Auto-generated method stub
return "jabber:client";
}
@Override
public String toXML() {
StringBuilder builder = new StringBuilder();
builder.append("<" + getElementName() + " xmlns=\"" + getNamespace()
+ "\">");
if (ftpUrl != null) {
builder.append("<ftpUrl>").append(ftpUrl).append("</ftpUrl>");
}
if (httpUrl != null) {
builder.append("<httpUrl>").append(httpUrl).append("</httpUrl>");
}
if (typeOfMessage != null) {
builder.append("<typeOfMessage>").append(typeOfMessage)
.append("</typeOfMessage>");
}
if (fieldName != null) {
builder.append("<fieldName>").append(fieldName)
.append("</fieldName>");
}
if (duration != null) {
builder.append("<duration>").append(duration).append("</duration>");
}
builder.append("</" + getElementName() + ">");
return builder.toString();
}
public String getUserRecipient() {
return userRecipient;
}
public void setUserRecipient(String userRecipient) {
this.userRecipient = userRecipient;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
我不知道是什麼在命名空間和元素通過。我瀏覽了文檔,但沒有找到解決方案。
請讓我知道這個問題出了什麼問題。反饋意見將幫助我解決問題,而不僅僅是提供一個downvote –