From f6c0046ae75de23a691d09e2ec4315820292dae8 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 8 Mar 2018 16:39:11 +0100 Subject: [PATCH] Fix crash when service is getting killed while in background --- src/android/org/linphone/LinphoneService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/android/org/linphone/LinphoneService.java b/src/android/org/linphone/LinphoneService.java index 85aaa21c8..e09629b57 100644 --- a/src/android/org/linphone/LinphoneService.java +++ b/src/android/org/linphone/LinphoneService.java @@ -821,7 +821,6 @@ public final class LinphoneService extends Service { @Override public synchronized void onDestroy() { - if (activityCallbacks != null){ getApplication().unregisterActivityLifecycleCallbacks(activityCallbacks); activityCallbacks = null; @@ -841,6 +840,12 @@ public final class LinphoneService extends Service { mNM.cancel(INCALL_NOTIF_ID); mNM.cancel(MESSAGE_NOTIF_ID); + // This will prevent the app from crashing if the service gets killed in background mode + if (LinphoneActivity.isInstanciated()) { + Log.w("Service is getting destroyed, finish LinphoneActivity"); + LinphoneActivity.instance().finish(); + } + super.onDestroy(); }