Reputation: 664
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);
}
this code is showing error "Cannot instantiate the type XMPPConnection" in eclipse with red underline
for following line:
XMPPConnection connection = new XMPPConnection(connConfig);
I am using asmack-android-8-4.0.0-rc2.jar, smack-resolver-dnsjava-4.0.0.jar as libs
Upvotes: 1
Views: 649
Reputation: 5867
If I remember correctly latest versions of ASmack require you to use a subclass of XMPPConnection and not the class itself. The fact that XMPPConnection can still has a public constructor is indeed misleading...
Try using XMPPTCPConnection instead:
Instead of:
XMPPConnection connection = new XMPPConnection(connConfig);
Use this:
XMPPTCPConnection conn = new XMPPTCPConnection(config);
Upvotes: 4