Fix oncreate not called when finishing after a crash

This commit is contained in:
Guillaume Beraudo 2011-11-28 11:48:32 +01:00
parent ce2bf4f9a1
commit 02ae758766
5 changed files with 17 additions and 6 deletions

View file

@ -69,6 +69,9 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li
* Called by the child classes AFTER their own onCreate. * Called by the child classes AFTER their own onCreate.
*/ */
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
if (finishIfAutoRestartAfterACrash(savedInstanceState)) {
return;
}
setListAdapter(mListAdapter = createCalleeListAdapter()); setListAdapter(mListAdapter = createCalleeListAdapter());
View muteMic = findViewById(R.id.toggleMuteMic); View muteMic = findViewById(R.id.toggleMuteMic);
@ -83,9 +86,10 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li
protected abstract CalleeListAdapter createCalleeListAdapter(); protected abstract CalleeListAdapter createCalleeListAdapter();
protected final boolean finishIfAutoRestartAfterACrash() { protected final boolean finishIfAutoRestartAfterACrash(Bundle savedInstanceState) {
if (!LinphoneManager.isInstanciated() || LinphoneManager.getLc().getCallsNb() == 0) { if (!LinphoneManager.isInstanciated() || LinphoneManager.getLc().getCallsNb() == 0) {
Log.e("No service running: avoid crash by finishing ", this.getClass().getName()); Log.e("No service running: avoid crash by finishing ", this.getClass().getName());
super.onCreate(savedInstanceState);
finish(); finish();
return true; return true;
} }

View file

@ -44,7 +44,9 @@ public class ConferenceDetailsActivity extends AbstractCalleesActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
if (finishIfAutoRestartAfterACrash()) return; if (finishIfAutoRestartAfterACrash(savedInstanceState)) {
return;
}
setContentView(R.layout.conference_details_layout); setContentView(R.layout.conference_details_layout);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }

View file

@ -89,7 +89,9 @@ public class IncallActivity extends AbstractCalleesActivity implements
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
if (finishIfAutoRestartAfterACrash()) return; if (finishIfAutoRestartAfterACrash(savedInstanceState)) {
return;
}
setContentView(R.layout.incall_layout); setContentView(R.layout.incall_layout);
mAllowTransfers = getResources().getBoolean(R.bool.allow_transfers); mAllowTransfers = getResources().getBoolean(R.bool.allow_transfers);

View file

@ -95,13 +95,15 @@ public class LinphoneActivity extends TabActivity implements
} }
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!LinphoneManager.isInstanciated()) { if (!LinphoneManager.isInstanciated()) {
Log.e("No service running: avoid crash by finishing ", this.getClass().getName()); Log.e("No service running: avoid crash by finishing ", this.getClass().getName());
// super.onCreate called earlier
finish(); finish();
return; return;
} }
instance = this; instance = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.main); setContentView(R.layout.main);
LinphonePreferenceManager.getInstance(this); LinphonePreferenceManager.getInstance(this);

View file

@ -60,13 +60,14 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
private Runnable mCallQualityUpdater; private Runnable mCallQualityUpdater;
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!LinphoneManager.isInstanciated() || LinphoneManager.getLc().getCallsNb() == 0) { if (!LinphoneManager.isInstanciated() || LinphoneManager.getLc().getCallsNb() == 0) {
Log.e("No service running: avoid crash by finishing ", this.getClass().getName()); Log.e("No service running: avoid crash by finishing ", this.getClass().getName());
// super.onCreate called earlier
finish(); finish();
return; return;
} }
Log.d("onCreate VideoCallActivity");
super.onCreate(savedInstanceState);
setContentView(R.layout.videocall); setContentView(R.layout.videocall);
SurfaceView videoView = (SurfaceView) findViewById(R.id.video_surface); SurfaceView videoView = (SurfaceView) findViewById(R.id.video_surface);