android xmpp 接收,android如何使用xmpp-smack在群聊中发送和接收图像和位置(使用地图)...

我使用android-xmpp开发群聊应用程序,因为我不知道如何发送和回放图片或图片或位置(使用地图).

所以任何一个人都可以请你给我这样做的方法.

目前,我收到短信并添加到列表视图,如下所示,

Message msg = new Message(to, Message.Type.groupchat);

msg.setBody(text);

if (Constants.connection != null) {

try {

Constants.connection.sendPacket(msg);

Log.d("Send to room : Name : ", to);

Log.d("store", "store data to db");

//DBAdapter.addUserData(new UserData(text, "", "1" ,beam_id));

} catch (Exception e) {

Log.d("ooo", "msg exception" + e.getMessage());

}

messages.add(text);

runOnUiThread(new Runnable() {

public void run() {

// set to listview

setMyChatAdapter();

}

});

}

并使用StanzaTypeFilter接收.那么图像和位置共享如何?

我使用smack-extensions-4.1.3-sources.jar尝试使用FileTransferManager跟踪图像代码.

private void sendImage()

{

FileTransferManager mg=new FileTransferManager(Constants.connection);

OutgoingFileTransfer transfer = mg.createOutgoingFileTransfer(beam_id+"@"+Constants.conference_name + "/" + Constants.resources);

File file = new File(selectedImagePath);

try {

transfer.sendFile(file, "test_file");

} catch (Exception e) {

e.printStackTrace();

}

while(!transfer.isDone()) {

if(transfer.getStatus().equals(FileTransfer.Status.error)) {

System.out.println("ERROR!!! " + transfer.getError());

} else if (transfer.getStatus().equals(FileTransfer.Status.cancelled)

|| transfer.getStatus().equals(FileTransfer.Status.refused)) {

System.out.println("Cancelled!!! "+ transfer.getError());

}

try {

Thread.sleep(1000L);

} catch (InterruptedException e) {

e.printStackTrace();

}

}

if(transfer.getStatus().equals(FileTransfer.Status.refused) || transfer.getStatus().equals(FileTransfer.Status.error)

|| transfer.getStatus().equals(FileTransfer.Status.cancelled)){

System.out.println("refused cancelled error"+ transfer.getError());

} else {

System.out.println("Success");

}

}

但是当我使用以下方式访问该文件时,

FileTransferManager mg = new FileTransferManager(Constants.connection);

它给我错误…有一个私人访问…所以,我发现该文件的构造函数是私有的,这是jar文件所以我不能将其更改为公共.

那么,我怎样才能将该文件类访问到我的班级?

那么,我如何在聊天中共享(发送 – 接收)图像和位置信息?

请尽快帮助我.

提前致谢.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值