Download - Fragment debugging
Debugging Android
Fragments
Meghaditya Roy ChaudhurySoftware Engineer, Citrix
Fragment – What and Why? Definition: A Fragment represents a behavior or a portion of
user interface in an activity.
Flexible UI
Re-usable
Embedded in the parent activity
Application specific subclasses –◦ DialogFragment, ListFragment, PreferenceFragment
Key Classes:
- Fragment
- FragmentManager
- FragmentTransaction
Ref: http://developer.android.com/guide/components/fragments.html
Fragment Life cycle
Concerns for Developers
Creation of fragments
◦ Adding UI
◦ Adding to parent activity
Management of fragments
Performing fragment transactions
Communicating with activities and
other fragments
Handling the fragment life-cycle
(Fragment + Activity) Lifecycle
FragmentManager.enableDebugLogging
(true)
Fragment in action
Fragment Debugging -
Terminology
moveFrom RESUMED – fragment.onPause()
moveFrom STARTED – fragment.onStop()
moveFrom ACTIVITY_CREATED – ??? [getActivity() is
destroyed]
moveFrom CREATED – fragment.onDestroy()
moveTo CREATED – fragment.onCreate()
moveTo ACTIVITY_CREATED – fragment.onActivityCreated()
moveTo STARTED – fragment.onStart()
moveTo RESUMED – fragment.onResume()
BackStackEntry Listing
BackStack Operations – add, commit, remove
MainActivity - onCreate
Application Launch – Debug
Log
Application moved to
Background
Application on Rotation
Safer to play by the book
Fragment best practices guidelines –
◦ Creating a fragment –
https://developer.android.com/training/basics/fr
agments/creating.html
◦ Building a flexible UI -
https://developer.android.com/training/basics/fr
agments/fragment-ui.html
◦ Communicating with other fragments –
https://developer.android.com/training/basics/fr
agments/communicating.html
Work Better. Live Better.
CITRIX