What is Activity.finish() method doing exactly?

前端 未结 12 1826
别那么骄傲
别那么骄傲 2020-11-22 16:16

I\'m developing android applications for a while, and followed a lot of posts about activity life cycle, and application\'s life cycle.

I know Activity.finish

12条回答
  •  感情败类
    2020-11-22 16:39

    calling finish in onCreate() will not call onDestroy() directly as @prakash said. The finish() operation will not even begin until you return control to Android.

    Calling finish() in onCreate(): onCreate() -> onStart() -> onResume(). If user exit the app will call -> onPause() -> onStop() -> onDestroy()

    Calling finish() in onStart() : onCreate() -> onStart() -> onStop() -> onDestroy()

    Calling finish() in onResume(): onCreate() -> onStart() -> onResume() -> onPause() -> onStop() -> onDestroy()

    For further reference check look at this oncreate continuous after finish & about finish()

提交回复
热议问题