今天。我正在使用 xmpp Api smack 开发一个 android 应用程序,我想在 openfire 服务器上获取聊天室,但是当我调用以下函数时:
Collection<HostedRoom> rooms = MultiUserChat.getHostedRooms(ClientConServer.connection,"conference." + ClientConServer.connection.getServiceName(
));
我收到以下错误:
08-12 15:53:50.754: E/AndroidRuntime(2897): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.multichat/com.example.multichat.QuestionsList}: java.lang.NullPointerException
08-12 15:53:50.754: E/AndroidRuntime(2897): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-12 15:53:50.754: E/AndroidRuntime(2897): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-12 15:53:50.754: E/AndroidRuntime(2897): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-12 15:53:50.754: E/AndroidRuntime(2897): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-12 15:53:50.754: E/AndroidRuntime(2897): at android.os.Handler.dispatchMessage(Handler.java:99)
08-12 15:53:50.754: E/AndroidRuntime(2897): at android.os.Looper.loop(Looper.java:137)
08-12 15:53:50.754: E/AndroidRuntime(2897): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-12 15:53:50.754: E/AndroidRuntime(2897): at java.lang.reflect.Method.invokeNative(Native Method)
08-12 15:53:50.754: E/AndroidRuntime(2897): at java.lang.reflect.Method.invoke(Method.java:525)
08-12 15:53:50.754: E/AndroidRuntime(2897): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-12 15:53:50.754: E/AndroidRuntime(2897): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-12 15:53:50.754: E/AndroidRuntime(2897): at dalvik.system.NativeStart.main(Native Method)
08-12 15:53:50.754: E/AndroidRuntime(2897): Caused by: java.lang.NullPointerException
08-12 15:53:50.754: E/AndroidRuntime(2897): at org.jivesoftware.smackx.muc.MultiUserChat.getHostedRooms(MultiUserChat.java:288)
08-12 15:53:50.754: E/AndroidRuntime(2897): at com.example.multichat.QuestionsList.onCreate(QuestionsList.java:78)
08-12 15:53:50.754: E/AndroidRuntime(2897): at android.app.Activity.performCreate(Activity.java:5133)
08-12 15:53:50.754: E/AndroidRuntime(2897): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-12 15:53:50.754: E/AndroidRuntime(2897): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-12 15:53:50.754: E/AndroidRuntime(2897): ... 11 more
我尽力在谷歌搜索这个问题,有人给出这样的建议: 在此处输入链接描述
但他们的方法对我不起作用?我需要你的帮助!