aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-07-28 21:58:04 +0200
committerChristian Schneppe <christian@pix-art.de>2016-07-28 21:58:04 +0200
commitf163f569b120e5e2093548a935c56dde7c918bbf (patch)
treeb2a22d8a31bb89f81a6bdbbc31fa0488dee4b48d /src/main/java
parentf6ff83a8cc0f2040dcf804ab62fe270a082f8d96 (diff)
fix crash on first start
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index dd708731c..3563100c1 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -523,12 +523,18 @@ public class NotificationService {
public Notification createForegroundNotification() {
final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
List<Account> accounts = mXmppConnectionService.getAccounts();
- Account mAccount = accounts.get(0);
- String status = "";
- if (mAccount.getStatus() == Account.State.ONLINE) {
- status = mXmppConnectionService.getString(R.string.account_status_online);
- } else if (mAccount.getStatus() == Account.State.CONNECTING) {
- status = mXmppConnectionService.getString(R.string.account_status_connecting);
+ String status;
+ Account mAccount = null;
+ Log.d(Config.LOGTAG, "Accounts size " + accounts.size());
+ if (accounts.size() > 0) {
+ mAccount = accounts.get(0);
+ if (mAccount.getStatus() == Account.State.ONLINE) {
+ status = mXmppConnectionService.getString(R.string.account_status_online);
+ } else if (mAccount.getStatus() == Account.State.CONNECTING) {
+ status = mXmppConnectionService.getString(R.string.account_status_connecting);
+ } else {
+ status = mXmppConnectionService.getString(R.string.account_status_offline);
+ }
} else {
status = mXmppConnectionService.getString(R.string.account_status_offline);
}
@@ -557,7 +563,7 @@ public class NotificationService {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mBuilder.setCategory(Notification.CATEGORY_SERVICE);
}
- if (mAccount.getStatus() == Account.State.ONLINE) {
+ if (accounts.size() > 0 && mAccount.getStatus() == Account.State.ONLINE) {
mBuilder.setSmallIcon(R.drawable.ic_link_white_24dp);
} else {
mBuilder.setSmallIcon(R.drawable.ic_unlink_white_24dp);