## 起動
com.example.android.dessertpusher I/MainActivity: onCreate Called
com.example.android.dessertpusher I/MainActivity: onStart called
com.example.android.dessertpusher I/MainActivity: onResume called
## App Switcherに移動
com.example.android.dessertpusher I/MainActivity: onPause called
com.example.android.dessertpusher I/MainActivity: onStop called
## 再びForegroundへ
com.example.android.dessertpusher I/MainActivity: onRestart called
com.example.android.dessertpusher I/MainActivity: onStart called
com.example.android.dessertpusher I/MainActivity: onResume called
## ホームボタンを押して、バックグラウンドへ
com.example.android.dessertpusher I/MainActivity: onPause called
com.example.android.dessertpusher I/MainActivity: onStop called
## 再びForegroundへ
com.example.android.dessertpusher I/MainActivity: onRestart called
com.example.android.dessertpusher I/MainActivity: onStart called
com.example.android.dessertpusher I/MainActivity: onResume called
## AppSwitcherから、プロセス終了
com.example.android.dessertpusher I/MainActivity: onPause called
com.example.android.dessertpusher I/MainActivity: onStop called
com.example.android.dessertpusher I/MainActivity: onDestroy called
# 起動
com.example.android.dessertpusher I/MainActivity: onCreate Called
com.example.android.dessertpusher I/MainActivity: onStart called
com.example.android.dessertpusher I/MainActivity: onResume called
# Backボタンを押下
com.example.android.dessertpusher I/MainActivity: onPause called
com.example.android.dessertpusher I/MainActivity: onDestroy called
com.example.android.dessertpusher I/MainActivity: onStop called
Timberを使用した。
class MainActivity : AppCompatActivity(), LifecycleObserver {
/** Lifecycle Methods **/
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Timber.i("onCreate Called")
}
override fun onStart() {
super.onStart()
Timber.i("onStart called")
}
// TODO (05) Here, override the rest of the lifecycle methods and use Timber to print
// log statements. Don't forget to update the log statement in onCreate!
/**
* Dispatch onResume() to fragments. Note that for better inter-operation
* with older versions of the platform, at the point of this call the
* fragments attached to the activity are *not* resumed. This means
* that in some cases the previous state may still be saved, not allowing
* fragment transactions that modify the state. To correctly interact
* with fragments in their proper state, you should instead override
* [.onResumeFragments].
*/
override fun onResume() {
super.onResume()
Timber.i("onResume called")
}
/**
* Dispatch onPause() to fragments.
*/
override fun onPause() {
super.onPause()
Timber.i("onPause called")
}
override fun onDestroy() {
super.onDestroy()
Timber.i("onDestroy called")
}
override fun onRestart() {
super.onRestart()
Timber.i("onRestart called")
}
override fun onStop() {
super.onStop()
Timber.i("onStop called")
}
}