Android 中 onSaveInstanceState()使用方法详解
2017-09-06 14:57
701 查看
Android 中 onSaveInstanceState()使用方法详解
覆盖onSaveInstanceState方法,并在onCreate中检测savedInstanceState和获取保存的值
@Override protected void onSaveInstanceState(Bundle outState) { outState.putInt("currentposition", videoView.getCurrentPosition()); super.onSaveInstanceState(outState); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); initView(); if (savedInstanceState != null && savedInstanceState.getInt("currentposition") != 0) { videoView.seekTo(savedInstanceState.getInt("currentposition")); } }
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
您可能感兴趣的文章:
相关文章推荐
- Android BaseSavedState 以及 Activity onSaveInstanceState 和 onRestoreInstanceState 方法使用注意事项
- Android使用详解之onSaveInstanceState和onRestoreInstanceState触发的时机
- android onSaveInstanceState的使用方法
- Android使用详解之onSaveInstanceState和onRestoreInstanceState触发的时机
- 【android学习】onSaveInstanceState使用详解-之解决问题:android程序崩溃后,app异常
- Android使用详解之onSaveInstanceState和onRestoreInstanceState触发的时机
- android onSaveInstanceState的使用方法
- Android使用详解之onSaveInstanceState和onRestoreInstanceState触发的时机
- android onSaveInstanceState的使用方法
- android onSaveInstanceState的使用方法
- android onSaveInstanceState方法
- Android学习札记36:一个关于onSaveInstanceState ()方法的例子
- android onSaveInstanceState 方法
- android onSaveInstanceState方法
- Android中用onSaveInstanceState保存Fragment状态的方法
- Android开发之onSaveInstanceState和onRestoreInstanceState详解
- android onSaveInstanceState方法
- android开发怎样测验onSaveInstanceState方法
- [转]android onSaveInstanceState方法
- Android Activity的onSaveInstanceState() 和 onRestoreInstanceState()方法