diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2bce65967..309e28424 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -189,6 +189,7 @@
+
@@ -244,8 +245,8 @@
-
+
diff --git a/src/org/linphone/BootReceiver.java b/src/org/linphone/BootReceiver.java
index aa2b1082c..f19591445 100644
--- a/src/org/linphone/BootReceiver.java
+++ b/src/org/linphone/BootReceiver.java
@@ -18,8 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone;
+import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LpConfig;
+import org.linphone.mediastream.Log;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -29,13 +31,20 @@ public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
-
- String path = context.getFilesDir().getAbsolutePath() + "/.linphonerc";
- LpConfig lpConfig = LinphoneCoreFactory.instance().createLpConfig(path);
- if (lpConfig.getBool("app", "auto_start", false)) {
- Intent lLinphoneServiceIntent = new Intent(Intent.ACTION_MAIN);
- lLinphoneServiceIntent.setClass(context, LinphoneService.class);
- context.startService(lLinphoneServiceIntent);
+ if (intent.getAction().equalsIgnoreCase(Intent.ACTION_SHUTDOWN)) {
+ LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
+ if (lc != null) {
+ Log.w("Device is shutting down, destroying LinphoneCore to unregister");
+ lc.destroy();
+ }
+ } else {
+ String path = context.getFilesDir().getAbsolutePath() + "/.linphonerc";
+ LpConfig lpConfig = LinphoneCoreFactory.instance().createLpConfig(path);
+ if (lpConfig.getBool("app", "auto_start", false)) {
+ Intent lLinphoneServiceIntent = new Intent(Intent.ACTION_MAIN);
+ lLinphoneServiceIntent.setClass(context, LinphoneService.class);
+ context.startService(lLinphoneServiceIntent);
+ }
}
}
}
diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java
index c73277966..6017b5d68 100644
--- a/src/org/linphone/LinphoneService.java
+++ b/src/org/linphone/LinphoneService.java
@@ -539,7 +539,11 @@ public final class LinphoneService extends Service {
public void onTaskRemoved(Intent rootIntent) {
if (getResources().getBoolean(R.bool.kill_service_with_task_manager)) {
Log.d("Task removed, stop service");
- LinphoneManager.getLc().setNetworkReachable(false);
+
+ // If push is enabled, don't unregister account, otherwise do unregister
+ if (LinphonePreferences.instance().isPushNotificationEnabled()) {
+ LinphoneManager.getLc().setNetworkReachable(false);
+ }
stopSelf();
}
super.onTaskRemoved(rootIntent);