问题描述
我只是想通过xmpp.I现在用asmack lib.I我下面让例外传送文件。
I am just trying to transfer a file through xmpp.I am using asmack lib.I am getting exception below.
E/AndroidRuntime( 332): FATAL EXCEPTION: main
E/AndroidRuntime( 332): java.lang.NullPointerException
E/AndroidRuntime( 332): at org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager.enableService(Socks5BytestreamManager.java:704)
E/AndroidRuntime( 332): at org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager.activate(Socks5BytestreamManager.java:696)
E/AndroidRuntime( 332): at org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager.getBytestreamManager(Socks5BytestreamManager.java:1
80)
E/AndroidRuntime( 332): at org.jivesoftware.smackx.filetransfer.Socks5TransferNegotiator.<init>(Socks5TransferNegotiator.java:50)
E/AndroidRuntime( 332): at org.jivesoftware.smackx.filetransfer.FileTransferNegotiator.<init>(FileTransferNegotiator.java:217)
E/AndroidRuntime( 332): at org.jivesoftware.smackx.filetransfer.FileTransferNegotiator.getInstanceFor(FileTransferNegotiator.java:102)
E/AndroidRuntime( 332): at org.jivesoftware.smackx.filetransfer.FileTransferManager.<init>(FileTransferManager.java:63)
E/AndroidRuntime( 332): at org.apache.android.xmpp.XMPPClient.fileTransfer(XMPPClient.java:143)
E/AndroidRuntime( 332): at org.apache.android.xmpp.XMPPClient.onClick(XMPPClient.java:200)
E/AndroidRuntime( 332): at android.view.View.performClick(View.java:2408)
E/AndroidRuntime( 332): at android.view.View$PerformClick.run(View.java:8816)
E/AndroidRuntime( 332): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 332): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 332): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 332): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 332): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 332): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 332): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 332): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
任何人可以帮助我,我该怎么办在Android中使用asmack文件传输?
can anybody help me how can i do a file transfer in android using asmack?
推荐答案
你必须做出一个虚拟的服务发现管理器。
you have to make a dummy service discovery manager.
new ServiceDiscoveryManager(your XMPP connection);
现在这条线不会引起任何问题。
now this line does not cause any problems.
mFileTransferManager = new FileTransferManager(your XMPP connection);
首先,你必须到smack.properties复制到你的Android模拟器。
你可以得到 smack.properties
在原来SMACK API的网站。
First, you have to copy a smack.properties to you android emulator.You can get smack.properties
at the original SMACK API site.
http://www.igniterealtime.org/downloads/source.jsp
推smack.properties成/数据/文件夹中。
push smack.properties into "/data/" folder.
修改初始化()
ProviderManager.java
方法(它在组织/ jivesoftware /拍/提供商
)如下:
Modify initialize()
method of ProviderManager.java
(it's in org/jivesoftware/smack/provider
) as follows.
查找以下行。
Enumeration providerEnum = classLoader.getResources(
"/META-INF/smack.providers");
将其替换
Enumeration providerEnum = classLoader.getResources(
"/data/smack.providers");
希望这有助于
这篇关于文件传输通过XMPP机器人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!