Question

I have a button in Android Application. When the button is clicked following code is invoked:

TestSmack a = new TestSmack();
a.login("abc@gmai.com","password");

I have a TestSmack class.....in the constructor of this class i wrote

public TestSmack ()
{
    ConnectionConfiguration connConfig = new 
          ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
    connection = new XMPPConnection(connConfig);
}

where XMPPConnection connection is a global variable. And in the login method I try to connect to the Server:

public void login(String userName, String password) throws XMPPException
{
    SASLAuthentication.supportSASLMechanism("PLAIN", 0);
    connection.connect();    
    connection.login(userName, password);
}

But it crashes. I don't know whats happening.

Whereas when I call these all methods from main() and run a simple Java application in separate project (Java, not Android) it works fine.

I am not able to figure out whats the problem.

Thanks

Was it helpful?

Solution

Are you using the standard Smack library? When I was playing around with XMPP some months ago, you had to patch the library to make it work on Android. Maybe this helps:

http://davanum.wordpress.com/2008/12/29/updated-xmpp-client-for-android/

OTHER TIPS

If anyone is not able to run the programme on android then check if the connect() and login() SMACK API are working fine or not.Because i figured out that u need to add

uses-permission android:name="android.permission.INTERNET" (enclose it within < />seperate braces)

in the AndroidManifest file for connect() and login() to work.And don't forget to use the patched Smack.jar.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top