13
I have been having very odd issues with Fragments and orientation changes that have been causing force closes and not following a logical pattern.
I created a simple Activity and Fragment lifecycle debugging application which simply implements every step of the Activity lifecycle and Fragment lifecycle by reporting the call to the logcat.
Here are the TestActivity and TestFragment classes:
TestActivity
public class TestActivity extends Activity {
Context ct = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.e("ACT", "onCreate called");
ct = getApplicationContext();
FrameLayout fl = new FrameLayout(ct);
fl.setId(1000);
TestFragment tf = new TestFragment();
getFragmentManager().beginTransaction().add(fl.getId(), tf, "").commit();
setContentView(fl);
}
@Override
protected void onStart() {
Log.e("ACT", "onStart called");
super.onStart();
}
@Override
protected void onResume() {
Log.e("ACT", "onResume called");
super.onResume();
}
@Override
protected void onPause() {
Log.e("ACT", "onPause called");
super.onPause();
}
@Override
protected void onStop() {
Log.e("ACT", "onStop called");
super.onStop();
}
@Override
protected void onDestroy() {
Log.e("ACT", "onDestroy called");
super.onDestroy();
}
@Override
protected void onRestart() {
Log.e("ACT", "onRestart called");
super.onRestart();
}
}
TestFragment
public