我正在开发Smack 4.2.0版本。我遇到了通过smack接收图像的问题,一切正常,同时发送短信和接收短信。我在回收图像时遇到异常
在回复超时内未收到任何回复。超时时间为30000毫秒(约30秒)。在等待流启动时
我已按照文档
http://download.igniterealtime.org/smack/docs/latest/documentation/extensions/filetransfer.html
我已经搜索过,我找到了增加数据包流超时但仍面临同样问题的解决方案
图片接收代码段
private void RecieveIncommingFiles() {
try{
if (mConnection != null){
FileTransferManager manager = FileTransferManager.getInstanceFor(mConnection);
manager.addFileTransferListener(new FileTransferListener() {
@Override
public void fileTransferRequest(FileTransferRequest request) {
IncomingFileTransfer transfer = request.accept();
try {
File file = new File("/storage/emulated/0/Download/" + transfer.getFileName());
transfer.recieveFile(file);
Log.d(TAG, "recieve success");
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
}catch (Exception e){
e.printStackTrace();
}
}
发送图片代码段
file = new File(getRealPathFromURI(imageUri));
// Create the file transfer manager
if (mConnection != null){
FileTransferManager manager = FileTransferManager.getInstanceFor(mConnection);
// Create the outgoing file transfer
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(JidCreate.entityFullFrom(recieverFullBareid));
transfer.sendFile(file, "Image!");
Log.d(TAG, "send success");
}