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?
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With