在OnCreate运行后的onActivityResult的蜂窝? [英] OnCreate runs AFTER onActivityResult on Honeycomb?
问题描述
我使用 startActivityForResult()
来让用户选择一个文件,形成了我的应用程序的文件系统。后该文件被选中,的onActivityResult()
运行和我的文件路径保存到一个变量,然后继续。这工作得很好的Android 2.3及更低。
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.
在蜂窝,然而,的OnCreate()
再次运行后 OnActivityReult()
,从根本上重新启动我的活动,所以我我无法因为它后,我得到的结果运行一个全新的活动举行任何变量。
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.
我能做些什么呢?
保存您的变量的onSaveInstanceState
方法。
在<一个href=\"http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState%28android.os.Bundle%29\"相对=nofollow>活动文档,他们给这可能是你的,读到它(在的onSaveInstanceState
方法的文档)。准确的情况下
In the Activity documentation they give an exact case which might be yours, read about it (In the onSaveInstanceState
method documentation).
这篇关于在OnCreate运行后的onActivityResult的蜂窝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!