protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat);
SmackAndroid.init(this);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
ConnectionConfiguration connConfig = new ConnectionConfiguration(HOST, PORT, SERVICE);
XMPPConnection connection = new XMPPConnection(connConfig);
}
此代码显示错误“无法实例化 XMPPConnection 类型” 在带红色下划线的 eclipse 中
对于以下行:
XMPPConnection connection = new XMPPConnection(connConfig);
我正在使用 asmack-android-8-4.0.0-rc2.jar, smack-resolver-dnsjava-4.0.0.jar 作为库
最佳答案
如果我没记错的话,最新版本的 ASmack 要求您使用 XMPPConnection 的子类,而不是类本身。 XMPPConnection 仍然可以具有公共(public)构造函数这一事实确实具有误导性......
尝试使用 XMPPTCPConnection相反:
代替:
XMPPConnection connection = new XMPPConnection(connConfig);
使用这个:
XMPPTCPConnection conn = new XMPPTCPConnection(config);
关于android - 无法以 asmack 开头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24489423/