Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OnCreate runs AFTER onActivityResult on Honeycomb?

I am using startActivityForResult() to allow the user to choose a file form the file system in my app. After the file is chosen, OnActivityResult() runs and I save the file path to a variable and proceed. This works fine on Android 2.3 and lower.

On Honeycomb, however, OnCreate() runs again AFTER OnActivityReult(), essentially restarting my activity so I am unable to hold any variables because it runs an entirely new activity after I get the result.

Any idea why this is, and what I can do about it?

like image 915
user1023127 Avatar asked Jan 18 '23 19:01

user1023127


1 Answers

One potential cause is in case the the device is low on memory, your activity was killed to claim system resources.

What can I do about it?

Save your variables in onSaveInstanceState method.

In the Activity documentation they give an exact case which might be yours, read about it (In the onSaveInstanceState method documentation).

like image 87
Jong Avatar answered Jan 31 '23 21:01

Jong