Activity methods:onCreate() and onDestroy()

后端 未结 2 1551
别跟我提以往
别跟我提以往 2021-01-31 00:12

When an activity is created for the first time then system calls the OnContentChanged() method as the first method and last call by system is the OnDetachedFr

2条回答
  •  天涯浪人
    2021-01-31 00:49

    onCreate():

    When an activity starts its life onCreate() is called. It is called only once in the lifecycle of an activity.

    onDestroy():

    onDestroy() is called when an activity finishes its life cycle. It is also called once in the lifecycle of an activity.

    onContentChanged():

    This hook is called whenever the content view of the screen changes (due to a call to Window.setContentView or Window.addContentView). For example you add new view to activity or want to refresh the list by calling notifyDataSetChanged().

    onDetachedFromWindow():

    Called when the main window associated with the activity has been detached from the window manager. For example, it is called when the current Activity goes into background or another activity came infront of current activity.

提交回复
热议问题