在activity的生命周期中,只要离开了可见阶段,或者说失去了焦点,activity就很可能被进程终止了!,被KILL掉了,,这时候,就需要有种机制,能保存当时的状态,这就是savedInstanceState的作用。

      当一个Activity在PAUSE时,被kill之前,它可以调用onSaveInstanceState()来保存当前activity的状态信息(在paused状态时,要被KILLED的时候)。用来保存状态信息的Bundle会同时传给两个method,即onRestoreInstanceState() and onCreate().

示例代码如下:

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xiaoxiao_job/archive/2010/08/31/5852811.aspx

相关文章:

  • 2022-02-05
  • 2022-01-02
  • 2022-12-23
  • 2023-03-20
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2021-04-02
猜你喜欢
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
相关资源
相似解决方案