1

today. I am using xmpp Api smack to develop an android application, I want to get the chatting rooms on the openfire server,but when I call the following function:

Collection<HostedRoom> rooms = MultiUserChat.getHostedRooms(ClientConServer.connection,"conference." + ClientConServer.connection.getServiceName());

I get the following error:

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

I tried my best to search this problem in google,someone give such advice: enter link description here

but their methods did not work for me? I need your help!

Community
  • 1
  • 1
minicaptain
  • 1,196
  • 9
  • 16

2 Answers2

0

Put <activity android:name=".QuestionsList"/> in your AndroidManifest.xml (Modify to suit where your activity is)

Vrashabh Irde
  • 14,129
  • 6
  • 51
  • 103
0

This is probably an initialization issue.

The java Smack reads at startup META-INF/smack-config.xml and loads the classes listed in there (thereby executing the static blocks in those classes). The Android asmack needs some work-arounds to get a correct initialization.

See also Cannot get list of public rooms from xmpp Server on Android?

Community
  • 1
  • 1
Marc Van Daele
  • 2,856
  • 1
  • 26
  • 52