Well, in my application I'm using default camera and gallery of Android with startActivityforResult as;
Intent i = new Intent("android.intent.action.PICK",
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
i.setType("image/*");
startActivityForResult(i, this.SELECT_PICTURE);
I am able to catch onActivityResult as well. However, if memory is low and I start this activity, I experienced that system is killing my parent activity, and even if the activity returns with a value, I lost all my local variables (and onCreate() is called again). Only onResume() should be called again.
I tried several times, I'm pretty sure that it is related with memory issue. If there is enough memory process is performed successfully. How can I prevent this behaviour?
Since Android doesn't kill application in foreground, can I still use this feature? I think my problem is almost similar with this one .
Solution
In addition to solution provided by Yahel, usage of following methods can work.
@Override
public void onSaveInstanceState(Bundle savedInstanceState){
super.onSaveInstanceState(savedInstanceState);
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState){
super.onRestoreInstanceState(savedInstanceState);
}