Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Fragment debugging

2,455 views

Published on

An android developer would know that fragments in the Android API are a powerful set of tools. But with that great power it puts great responsibility on the developer.

Fragment debugging is an informative presentation on how to effectively use android fragments.

Published in: Technology
  • Be the first to comment

Fragment debugging

  1. 1. Debugging Android Fragments Meghaditya Roy Chaudhury Software Engineer, Citrix
  2. 2. 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
  3. 3. Fragment Life cycle
  4. 4. 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
  5. 5. (Fragment + Activity) Lifecycle
  6. 6. FragmentManager.enableDebugLogging (true)
  7. 7. Fragment in action
  8. 8. 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
  9. 9. MainActivity - onCreate
  10. 10. Application Launch – Debug Log
  11. 11. Application moved to Background
  12. 12. Application on Rotation
  13. 13. 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
  14. 14. Work Better. Live Better. CITRIX

×