diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-10-18 21:52:03 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-10-18 21:52:03 +0200 |
commit | 92c0e993ad3362d1b2ec75f7886bbc2e01f3d253 (patch) | |
tree | 142be77c3e4830e7daa8046062513539538ba317 /src/main/java | |
parent | d285abb5d6e3d50f4b8e4f71ac724735b7282c8a (diff) |
add exception handling when loading default resource
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 8f66b1971..02725991b 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -1131,7 +1131,16 @@ public class XmppConnectionService extends Service { public XmppConnection createConnection(final Account account) { final SharedPreferences sharedPref = getPreferences(); - account.setResource(sharedPref.getString("resource", "mobile").toLowerCase(Locale.getDefault())); + String resource; + try { + resource = sharedPref.getString("resource", getString(R.string.default_resource)).toLowerCase(Locale.ENGLISH); + if (resource.trim().isEmpty()) { + throw new Exception(); + } + } catch (Exception e) { + resource = "Pix-Art Messenger"; + } + account.setResource(resource); final XmppConnection connection = new XmppConnection(account, this); connection.setOnMessagePacketReceivedListener(this.mMessageParser); connection.setOnStatusChangedListener(this.statusListener); |