面对嫌使用android上的问题 [英] facing problem using smack on android

查看:165
本文介绍了面对嫌使用android上的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android应用程序的按钮。当点击以下code按钮调用:

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");

我有一个TestSmack类.....在这个类我写的构造函数

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);
}

,其中XMPPConnection连接是一个全局变量。而在登录方法我尝试连接到服务器:

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.

而当我打电话从所有这些方法的main(),并运行在单独的项目(Java中,没有Android设备),它工作正常。一个简单的Java应用程序

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.

感谢

推荐答案

您使用标准库啪?当我在几个月前玩弄XMPP,你不得不补丁库,使其在Android上工作。也许这可以帮助:

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 .word press.com / 2008/12/29 /更新-XMPP协议的客户端换的Andr​​oid /

这篇关于面对嫌使用android上的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆