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")); } }
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!