add exception handling when loading default resource
This commit is contained in:
parent
dc02e2b498
commit
22d13a3dcd
|
@ -997,8 +997,16 @@ public class XmppConnectionService extends Service {
|
||||||
|
|
||||||
public XmppConnection createConnection(final Account account) {
|
public XmppConnection createConnection(final Account account) {
|
||||||
final SharedPreferences sharedPref = getPreferences();
|
final SharedPreferences sharedPref = getPreferences();
|
||||||
account.setResource(sharedPref.getString("resource", getString(R.string.default_resource))
|
String resource;
|
||||||
.toLowerCase(Locale.getDefault()));
|
try {
|
||||||
|
resource = sharedPref.getString("resource", getString(R.string.default_resource)).toLowerCase(Locale.ENGLISH);
|
||||||
|
if (resource.trim().isEmpty()) {
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
resource = "conversations";
|
||||||
|
}
|
||||||
|
account.setResource(resource);
|
||||||
final XmppConnection connection = new XmppConnection(account, this);
|
final XmppConnection connection = new XmppConnection(account, this);
|
||||||
connection.setOnMessagePacketReceivedListener(this.mMessageParser);
|
connection.setOnMessagePacketReceivedListener(this.mMessageParser);
|
||||||
connection.setOnStatusChangedListener(this.statusListener);
|
connection.setOnStatusChangedListener(this.statusListener);
|
||||||
|
|
Loading…
Reference in a new issue