0
votes

I want to create a messaging application for Android, so I've been reading up about XMPP and Asmack. Asmack sounds pretty much exactly what I want, especially after reading this other question - Android and XMPP: Currently available solutions.

However, I'm fairly new to Android programming and also Github.

I have found the src for Asmack at https://github.com/Flowdalic/asmack, and also downloaded the jar from http://asmack.freakempire.de/4.0.4/, which I have included in my project. However I am unsure how the folders in the github asmack folder are supposed to be used. After hours trawling google trying to find some sort of step by step guide on how to set aSmack up, and not finding anything useful, I'm losing the will to live!

I'm using the following example code I found on the Smack github page, and I dont get any errors:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    XMPPTCPConnection connection = new XMPPTCPConnection("jabber.org");
    try {
        connection.connect();
        connection.login("mtucker", "password");
    } catch (SmackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (XMPPException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    Chat chat = ChatManager.getInstanceFor(connection)
        .createChat("[email protected]", new MessageListener() {

        public void processMessage(Chat chat, Message message) {
            System.out.println("Received message: " + message);
        }

    });
    try {
        chat.sendMessage("Howdy!");
    } catch (NotConnectedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (XMPPException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


}

However I haven't used the 'build environment' from aSmack github repository - how is this meant to be included/used?

Thanks for any help!

1
I think you only need the jar file.Georgian Benetatos
Okay, thanks for your help.matt
I think the source is compiled to the jar to serve as library.Georgian Benetatos

1 Answers

0
votes

You need to add single Jar file (last version now is 4.0.6) to your library and also don't forget to set proper permissions in manifest file.