Problem using smack on android

I have a button in an android application. When the button is pressed, the following code is called:

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

I have a class TestSmack ..... 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 the 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 he is falling. I do not know what's going on.

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

I can’t understand what the problem is.

thank

+3
source share
2 answers

- android, , API- connect() login() SMACK . ,

- android: name= "android.permission.INTERNET" ( </" > )

AndroidManifest () login() . Smack.jar.

+2

Source: https://habr.com/ru/post/1765603/


All Articles