fragment debugging

Post on 08-Jul-2015

223 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

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.

TRANSCRIPT

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

top related