javaandroidxmppsmack

How to get XMPP Service Domain as a String Smack 4


I am trying to save some values in a array of String as bellow:

     String hosts[] = new String[] {
            connection.getXMPPServiceDomain(),
            connection.getHost(),
            "im.etidlab.cd", //fallback on im.etidlab.cd
    };

Where connection is an instance of AbstractXMPPConnection. But the problem is the method connection.getXMPPServiceDomain() returns org.jxmpp.jid.DomainBareJid and not a String .

How can I get XMPP Service Domain as a String ?(I am a newbie in java)


Solution

  • DomainBareJid extends Jid.java and so, you just need to use toString() function as below.

    connection.getXMPPServiceDomain().toString()

    Of course, you can download the source at github or official site to check on for further learning.