I have my activity which uses user defined objects to keep track of progress. I need to fetch an image from camera when user presses a button and store it in one of these objects.
The problem is that sometimes it works fine but many times it re-initializes my activity and hence all the objects and my progress is lost. As far as i understand it might be because camera is a memory intensive app and while in background, the OS destroys my app to free memory.
I would prefer not to make my objects Parcable and then save them to the Bundle.
I have modified my manifest for android so that activity tag include
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait"
Here is my camera intent
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(takePictureIntent,REQUEST_IMAGE_CAPTURE);
Here is onActivityResult method
protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == Activity.RESULT_OK )
modifyResponseView_image();
}
I have tried many more suggestions and feel that keeping my activity in foreground might help but am not sure about if it will nor how to do it.
Any help you can provide will be deeply appreciated. Alternatives to apply this functionality will also help.