Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8355057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:44:41+00:00 2026-06-09T09:44:41+00:00

Hello Everyone i am new to android and i am currently stuck on this.

  • 0

Hello Everyone i am new to android and i am currently stuck on this.
I have to return list of public rooms created on xmpp server. The problem i am having is that the code below works fine for java but there is a null pointer exception in case of android.
Any help regarding this would be appreciated.

I am using an openfire server and testing it on local machine so that is the reason why i am using ip Address instead of domain name.

I am using smack library for JAVA and Asmack Library for android

String server_name = "192.168.3.113";
    ConnectionConfiguration config = new ConnectionConfiguration(
            server_name, 5222);
    XMPPConnection connection = new XMPPConnection(config);
    try {
        connection.connect();

        connection.login("s1", "123");

        Collection<HostedRoom> rooms = MultiUserChat.getHostedRooms(
                connection, "conference.geekoid");
        for (HostedRoom room : rooms) {
            System.out.println(room.getName());
        }

    } catch (XMPPException e) {
        System.out.println("Error" + e.getMessage() + "\n"); //for JAVA
                    log.e("Android Error",e.getmessage());  // For Android
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:44:44+00:00Added an answer on June 9, 2026 at 9:44 am

    I have found the Solution to the problem.

    The Android asmack library was using this in
    getHostedRooms(Connection connection,
    String serviceName)
    method

    ServiceDiscoveryManager discoManager =ServiceDiscoveryManager.getInstanceFor(connection);
    

    i replaced it with

    ServiceDiscoveryManager discoManager = new ServiceDiscoveryManager(connection);
    

    For those who are confused where this method is its in

    Package: org.jivesoftware.smackx.muc

    File: MultiUserChat.java

    After you have done this. We have to register all the providers in Android whose detail can be found here. These providers are automatically registered when are using JAVA’s smack library (In java Development) but in Android we have to register them ourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Everyone I am new being in ANDROID so I am getting one problem
hello everyone I have this snippet of the code: void* Init(int N) { Hand
Hello Everyone I'm really new bee in android and for that I'm confused to
Hello everyone I have an objective-c dilema :P I am quite new to objective-c,
hello everyone i have a 2D array. I am printing the elements of this
Hello everyone I am completely stuck with this problem. I want add the name
Hello everyone, I have been banging my head really hard trying to solve this
Hello everyone i am new to rails just wanted to ask What this line
Hello everyone I am new to blackberry and I want a textfield that scroll
hello everyone I am trying to make a script that steps through a list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.