Top Banner
Debugging Android Fragments Meghaditya Roy Chaudhury Software Engineer, Citrix
14

Fragment debugging

Jul 08, 2015

Download

Technology

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.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Fragment debugging

Debugging Android

Fragments

Meghaditya Roy ChaudhurySoftware Engineer, Citrix

Page 2: Fragment debugging

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

Page 3: Fragment debugging

Fragment Life cycle

Page 4: Fragment debugging

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

Page 5: Fragment debugging

(Fragment + Activity) Lifecycle

Page 6: Fragment debugging

FragmentManager.enableDebugLogging

(true)

Page 7: Fragment debugging

Fragment in action

Page 8: Fragment debugging

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

Page 9: Fragment debugging

MainActivity - onCreate

Page 10: Fragment debugging

Application Launch – Debug

Log

Page 11: Fragment debugging

Application moved to

Background

Page 12: Fragment debugging

Application on Rotation

Page 13: Fragment debugging

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

Page 14: Fragment debugging

Work Better. Live Better.

CITRIX