06-27 05:46
Notice
Recent Posts
Recent Comments
06-27 05:46
«   2024/06   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
Archives
Today
Total
관리 메뉴

pear

[android] Life Cycle 본문

android

[android] Life Cycle

pearlab 2023. 8. 9. 14:09

Life Cycle
액티비티 

액티비티가 시작하는 순간부터 종료되는 순간까지의 주기를 말한다.
onCreate(): 액티비티가 시작될 때 레이아웃을 구성하면서 한 번 실행
onStart(): 액티비티가 사용자에게 보이기 직전에 실행. BroadcastReceiver 실행
onResume(): 사용자가 액티비티와 상호작용하는 기능을 넣는 곳으로, 무조건 실행되어야 하는 기능이 들어감
onPause(): 포커스를 잃어 화면이 부분적으로는 보이지만 곧 사라질 때 실행
onStop(): 사용자에게서 화면이 완전히 사라지고, 다른 액티비티가 보여질 때 호출
onDestroy(): (화면회전 혹은)화면이 완전히 종료되기 직전에 호출

프래그먼트 

       
  onCreate(), 
onStart(), 
onResume(), 
onPause(), 
onStop(), 
onDestroy().
onCreate
onCreateView
onViewCreated
onViewStateResotred
onStart
onResume
onPause
onStop
onSaveInstanceState
onDestoryView
onDestory
onAttach(Activity) 
called once the fragment is associated with its activity.
onCreate(Bundle) 
called to do initial creation of the fragment.
onCreateView(LayoutInflater, ViewGroup, Bundle) 
creates and returns the view hierarchy associated with the fragment.
onActivityCreated(Bundle) 
tells the fragment that its activity has completed its own Activity.onCreate().
onViewStateRestored(Bundle) 
tells the fragment that all of the saved state of its view hierarchy has been restored.
onStart() 
makes the fragment visible to the user (based on its containing activity being started).
onResume() 
makes the fragment begin interacting with the user (based on its containing activity being resumed).


onPause() 
fragment is no longer interacting with the user either because its activity is being paused or a fragment operation is modifying it in the activity.
onStop() 
fragment is no longer visible to the user either because its activity is being stopped or a fragment operation is modifying it in the activity.
onSaveInstanceState()
onDestroyView() 
allows the fragment to clean up resources associated with its View.
onDestroy() 
called to do final cleanup of the fragment's state.
onDetach() 
called immediately prior to the fragment no longer being associated with its activity.

 

https://developer.android.com/guide/fragments/lifecycle

 

https://developer.android.com/guide/fragments/lifecycle