diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java index f92e6a6ec..34de67cc9 100644 --- a/src/org/linphone/DialerActivity.java +++ b/src/org/linphone/DialerActivity.java @@ -386,6 +386,10 @@ public class DialerActivity extends SoftVolumeActivity implements LinphoneGuiLis public void onCallStateChanged(LinphoneCall call, State state, String message) { LinphoneCore lc = LinphoneManager.getLc(); + if (lc==null) { + /* we are certainly exiting, ignore then.*/ + return; + } if (state == LinphoneCall.State.OutgoingInit) { enterIncallMode(lc); } else if (state == LinphoneCall.State.IncomingReceived) { diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index ea988465c..c3c74740c 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -113,9 +113,11 @@ public final class LinphoneManager implements LinphoneCoreListener { private static LinphonePreferenceManager lpm; private String lastLcStatusMessage; private String basePath; + private static boolean sExited; private LinphoneManager(final Context c) { + sExited=false; basePath = c.getFilesDir().getAbsolutePath(); linphoneInitialConfigFile = basePath + "/linphonerc"; linphoneConfigFile = basePath + "/.linphonerc"; @@ -209,14 +211,16 @@ public final class LinphoneManager implements LinphoneCoreListener { return instance; } - public static final LinphoneManager getInstance() { + public static synchronized final LinphoneManager getInstance() { if (instance != null) return instance; - throw new RuntimeException("Linphone Manager should be created before accessed"); + if (!sExited) throw new RuntimeException("Linphone Manager should be created before accessed"); + return null; } - public static final LinphoneCore getLc() { - return getInstance().mLc; + public static synchronized final LinphoneCore getLc() { + LinphoneManager m=getInstance(); + return m!=null ? m.mLc : null; } @@ -592,7 +596,7 @@ public final class LinphoneManager implements LinphoneCoreListener { public static synchronized void destroy(Context context) { if (instance == null) return; - + sExited=true; try { instance.mTimer.cancel(); instance.mLc.destroy();