Works by

Ren's blog

@rennnosuke_rk 技術ブログです

Android:rotate時のActivity再生成

すごい雑だけどメモ。

Caution: Your activity will be destroyed and recreated each time the user rotates the screen. When the screen changes orientation, the system destroys and recreates the foreground activity because the screen configuration has changed and your activity might need to load alternative resources (such as the layout).

画面回転をアプリ側で許可している時、回転した瞬間にActivityは再生成されている。 再生成される前の情報はBundleオブジェクトに保存され、再度読み込まれる。

再生成するのは、画面回転によるパラメタの変更に際して別のリソースが必要となるため。

あとBundleオブジェクトは各々のViewの情報を保持できるKVS(Key-Value Store)で、Activityがdestroyされても生きている。例えばChromeブラウザを終了しても前回開いたタブ情報がそのまま、といった事が可能になる。

参考サイト

http://developer.android.com/training/basics/activity-lifecycle/recreating.html