diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index ae84a86329..327da86476 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1376,10 +1376,9 @@ public class FragmentCompose extends FragmentEx { public void onItemSelected(AdapterView parent, View view, int position, long id) { EntityAccount account = (EntityAccount) parent.getAdapter().getItem(position); - if (liveIdentities == null) - liveIdentities = db.identity().liveIdentities(account.id, true); - else + if (liveIdentities != null) liveIdentities.removeObservers(getViewLifecycleOwner()); + liveIdentities = db.identity().liveIdentities(account.id, true); liveIdentities.observe(getViewLifecycleOwner(), new Observer>() { @Override diff --git a/app/src/main/java/eu/faircode/email/ServiceTileUnseen.java b/app/src/main/java/eu/faircode/email/ServiceTileUnseen.java index 74ed500027..d708fdcfbb 100644 --- a/app/src/main/java/eu/faircode/email/ServiceTileUnseen.java +++ b/app/src/main/java/eu/faircode/email/ServiceTileUnseen.java @@ -86,8 +86,10 @@ public class ServiceTileUnseen extends TileService { public void onStopListening() { Log.i(Helper.TAG, "Stop tile unseen"); - if (liveMessages != null) + if (liveMessages != null) { liveMessages.removeObservers(owner); + liveMessages = null; + } } public void onClick() {