アクティビティのお話
アクティビティのライフサイクルをメイン画面→サブ画面表示→ホームボタン押下→タスクの再起動→戻るボタン押下→戻るボタン押下で追ってみた
// メイン画面表示 Main.onCreate // 初期処理 Main.onStart // 表示開始直前処理 Main.onResume // 準備完了処理 // サブ画面表示 Main.onPause // 非表示直前処理 Sub.onCreate Sub.onStart Sub.onResume Main.onStop // 停止処理 // ホームボタン押下 Sub.onPause Sub.onStop // タスクから再起動 Sub.onRestart // 停止復帰処理 Sub.onStart Sub.onResume // 戻るボタンでサブ画面を終了 Sub.onPause Main.onRestart Main.onStart Main.onResume Sub.onStop Sub.onDestroy // 破棄直前処理 // 戻るボタンでメイン画面を終了 Main.onPause Main.onStop Main.onDestroy