OnCreate runs AFTER onActivityResult on Honeycomb?

不羁的心 提交于 2019-12-14 01:06:01

问题


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?


回答1:


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).



来源:https://stackoverflow.com/questions/8825448/oncreate-runs-after-onactivityresult-on-honeycomb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!