Why should I need to use setRetainInstance()
or onSaveInstance()
to save state and I can use android:configChanges="keyboard|orientation|screenLayout"
and get the samething "saving state non-UI state"? I mean with less headache.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Don't use
android:configChanges
. It will break things in subtle ways and will prevent Android from getting the proper layout/theme/dimensions, etc. for the current configuration.onSaveInstanceState()
is completely orthogonal to this: you need to save state so you can restore it if Android kills your process to save memory.configChagnes
only prevents it from re-creating the activity on rotation, keyboard state changes, etc.setRetainInstance()
is for fragments that you don't want re-created on device rotation, etc. If you don't call it, Android will serialize their state in a Bundle, and re-create them along with the parent activity.In short, while
configChanges
appears to be a 'shortcut' it is not. Don't rely on it and save/restore state as necessary using the proper tools for each case.