powered by Jive Software

Android/aSmack Error on Eclipse - Application Exits

Can anyone tell me what is wrong with my code?

MY CODE:

package power.pack;

import android.app.Activity;

import android.os.Bundle;

import android.util.Log;

import org.jivesoftware.smack.Chat;

import org.jivesoftware.smack.ChatManager;

import org.jivesoftware.smack.MessageListener;

import org.jivesoftware.smack.PacketCollector;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.XMPPException;

import org.jivesoftware.smack.filter.AndFilter;

import org.jivesoftware.smack.filter.FromContainsFilter;

import org.jivesoftware.smack.filter.PacketFilter;

import org.jivesoftware.smack.filter.PacketTypeFilter;

import org.jivesoftware.smack.packet.Message;

import org.jivesoftware.smack.packet.Packet;

public class PowerActivity extends Activity {

public int state = 0;

private static final String TAG = "HelloFormStuffActivity";

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);      

    new Thread(new Runnable() {

      public void run() {           

       XMPPConnection xmpp = new XMPPConnection("jabbernamehere.com");

       // XMPPConnection xmpp = new XMPPConnection("gmail.com");

        try {

         // xmpp.connect();

          // for other jabber accounts, truncate after the @

          xmpp.login("usernamehere, "passwordhere");

          // for gtalk / gmail, include the @

          //xmpp.login("your-gmail-account@gmail.com", "your-gmail-password");

        } catch (XMPPException e) {

          Log.v(TAG, "Failed to connect to " + xmpp.getHost());

          e.printStackTrace();

        }

        ChatManager chatmanager = xmpp.getChatManager();

        Chat newChat = chatmanager.createChat("friend@gmail.com", new MessageListener() {

          // THIS CODE NEVER GETS CALLED FOR SOME REASON

          public void processMessage(Chat chat, Message message) {

            try {

              Log.v(TAG, "Got:" + message.getBody());

              chat.sendMessage(message.getBody());

            } catch (XMPPException e) {

              Log.v(TAG, "Couldn't respond:" + e);

            }

            Log.v(TAG, message.toString());

          }

        });

        // Send something to friend@gmail.com

        try {

          newChat.sendMessage("OMNOMNOM");

        } catch (XMPPException e) {

          Log.v(TAG, "couldn't send:" + e.toString());

        }

        // Accept only messages from friend@gmail.com

        PacketFilter filter

            = new AndFilter(new PacketTypeFilter(Message.class),

                            new FromContainsFilter("friend@gmail.com"));

        // Collect these messages

        PacketCollector collector = xmpp.createPacketCollector(filter);

        while(true) {

          Packet packet = collector.nextResult();

          if (packet instanceof Message) {

            Message msg = (Message) packet;

            // Process message

            Log.v(TAG, "Got message:" + msg.getBody());

          }

        }

      }

    }).start();

    //setContentView(this);

}

}

Errors attached.

I am using this asmack-android-7.jar : (https://github.com/Flowdalic/asmack/downloads)