Android的startActivityForResult方向改变 [英] Android startActivityForResult orientation change
问题描述
我使用的启动活动的结果,以帮助我的应用程序过滤器的一些信息出来的用户。一旦信息被过滤,我把它添加到意图,然后调用完成。完美除了当用户旋转设备时,他们正在执行的滤波的作品。这将导致第一个活动再次创造一切都结束了,因为这种情况下我的过滤选项被全歼(他们完成之前的onCreate结束所以UI被清除)。在某种程度上任何想法来处理呢?
谢谢
I am using start activity for result to help users of my application filter some information out. Once the information is filtered i add it to the intent and then call finish. The works perfectly except for when the users have rotated the device when they are performing the filtering. This causes the first activity to create all over again and since this happens my filtering options are wiped out (They finish before onCreate is over so the UI is cleared). Any ideas on a way to handle this? Thanks
推荐答案
有3个选项做到这一点。
There are 3 options to do this
-
的onSaveInstanceState()
//但通常能够处理的数据量小
onSaveInstanceState()
// But can usually handle small amount of data
onRetainNonConfigurationInstance()和getLastNonConfigurationInstance()
// preferred
onRetainNonConfigurationInstance() and getLastNonConfigurationInstance()
//Preferred
的android:configChanges =方向| keyboardHidden
在AndroidManifest.xml
android:configChanges="orientation|keyboardHidden"
in AndroidManifest.xml
//这不会让得到重新启动该活动,用这个当你想保存的数据不是large.For API 13+使用的android:configChanges =方向|屏幕尺寸
// This will not let the activity to get restarted, use this when the data you want to conserve is not large.For api 13+ use this android:configChanges="orientation|screenSize"
这篇关于Android的startActivityForResult方向改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!