gpt4 book ai didi

android - 无法使用 asmack 接收文件

转载 作者:行者123 更新时间:2023-11-29 14:05:46 24 4
gpt4 key购买 nike

我无法使用 asmack 接收文件,但我能够发送文件。下面是接收文件的代码,请告诉我我做错了什么

             ServiceDiscoveryManager serv=  new ServiceDiscoveryManager(ConnectionActivity.m_connection);
FileTransferManager manger=new FileTransferManager(ConnectionActivity.m_connection);
manger.addFileTransferListener(new FileTransferListener(){

@Override
public void fileTransferRequest(FileTransferRequest request) {
// TODO Auto-generated method stub
Log.v("request", "accept");
IncomingFileTransfer transfer = request.accept();
transfer=request.accept();
Log.v("status",transfer.getStatus()+"");
Log.v("filename",transfer.getFileName()+"");//im able to get filename
File file=new File(Environment.getExternalStorageDirectory()+"/off","downloaded");
try {
transfer.recieveFile(file);
} catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}



}

});

最佳答案

添加这个:

// //File transfer
pm.addIQProvider("si", "http://jabber.org/protocol/si",
new StreamInitiationProvider());
pm.addIQProvider("query", "http://jabber.org/protocol/bytestreams",
new BytestreamsProvider());
pm.addIQProvider("open", "http://jabber.org/protocol/ibb",
new OpenIQProvider());
pm.addIQProvider("close", "http://jabber.org/protocol/ibb",
new CloseIQProvider());
pm.addExtensionProvider("data", "http://jabber.org/protocol/ibb",
new DataPacketProvider());

关于android - 无法使用 asmack 接收文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7158201/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com