diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java b/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java index 93b349c..b0df440 100644 --- a/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java +++ b/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java @@ -43,11 +43,6 @@ public abstract class SetupPageFragment extends Fragment { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); - Bundle args = getArguments(); - mKey = args.getString(Page.KEY_PAGE_ARGUMENT); - if (mKey == null) { - throw new IllegalArgumentException("No KEY_PAGE_ARGUMENT given"); - } SetupStats.addEvent(SetupStats.Categories.PAGE_LOAD, SetupStats.Action.PAGE_LOADED, mKey, String.valueOf(System.currentTimeMillis())); } @@ -65,6 +60,11 @@ public abstract class SetupPageFragment extends Fragment { @Override public void onAttach(Activity activity) { super.onAttach(activity); + Bundle args = getArguments(); + mKey = args.getString(Page.KEY_PAGE_ARGUMENT); + if (mKey == null) { + throw new IllegalArgumentException("No KEY_PAGE_ARGUMENT given"); + } if (!(activity instanceof SetupDataCallbacks)) { throw new ClassCastException("Activity implement SetupDataCallbacks"); } @@ -90,6 +90,11 @@ public abstract class SetupPageFragment extends Fragment { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { + // On low mem devices, this fragment might get destroyed by + // fragment manager while we are in another activity. + if (mPage == null) { + mPage = mCallbacks.getPage(mKey); + } mPage.onActivityResult(requestCode, resultCode, data); }