diff --git a/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java b/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java index 0dbf3e7c85..8a1dc89176 100644 --- a/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java +++ b/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java @@ -61,6 +61,7 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA protected void onResume() { Log.i(TAG, "onResume()"); super.onResume(); + isVisible = true; // Android P has a bug in foreground timings where starting a service in onResume() can still crash Util.postToMain(() -> { @@ -69,19 +70,19 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStarted(this); else ApplicationContext.getInstance(this).getJobManager().add(new PushNotificationReceiveJob(this)); }); - - isVisible = true; } @Override protected void onPause() { Log.i(TAG, "onPause()"); super.onPause(); - KeyCachingService.registerPassphraseActivityStopped(this); - - if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStopped(this); - isVisible = false; + + // Android P has a bug in foreground timings where starting a service in onPause() can still crash + Util.postToMain(() -> { + KeyCachingService.registerPassphraseActivityStopped(this); + if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStopped(this); + }); } @Override diff --git a/src/org/thoughtcrime/securesms/WebRtcCallActivity.java b/src/org/thoughtcrime/securesms/WebRtcCallActivity.java index 3112079317..9ce0d8547c 100644 --- a/src/org/thoughtcrime/securesms/WebRtcCallActivity.java +++ b/src/org/thoughtcrime/securesms/WebRtcCallActivity.java @@ -115,8 +115,12 @@ public class WebRtcCallActivity extends Activity { public void onPause() { Log.i(TAG, "onPause"); super.onPause(); - if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStopped(this); EventBus.getDefault().unregister(this); + + // Android P has a bug in foreground timings where starting a service in onPause() can still crash + Util.postToMain(() -> { + if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStopped(this); + }); } @Override