Tuesday, May 28, 2013

Android Fragment Life Cycle



onAttach:_  ( Activity) called once the fragment is associated with its activity.

onCreate():-

System calls this method while creating new fragment. If user want to remain essential componet while other methods call like onPause() or onResume() methods.
    
onCreateView():-
System calls this method when View to be added in activity or draw user interface for user view. it will return View from the method. if we return null, it will not show UI in application.
    









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 interacting with the user (based on its containing activity being resumed).
As a fragment is no longer being used, it goes through a reverse series of callbacks:


onPause():_It indicate that user leaves this fragment , but it is not going to destroyed. 

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.

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.

    


No comments:

Post a Comment