Fragments for All

App Development Grand Ballroom B
Presentation: Fragments for All Presentation [PDF]
Average rating: ****.
(4.67, 6 ratings)

Android 3.0 introduced the Fragment class, intended to represent a behavior or portion of a user interface in an Activity. Since then, Google has released the Android Compatibility package to extend Fragment support to devices running Android 1.6 or later.

Fragments allow you to decompose the functionality and user interface of an application into reusable modules. You can then implement your Activities to assemble difference combinations of Fragments depending on the screen size and orientation of the device — for example, taking advantage of the large screen size of a tablet while still supporting smaller handheld devices.

However, Fragments provide benefits beyond improving your application’s support for multiple screen sizes. For example, Fragments allow you to:

  • Simplify implementing tabbed interfaces and other dynamic interfaces
  • Provide intra-Activity Back button behavior that integrates with the existing Activity back stack
  • Easily retain state information across an Activity’s runtime configuration change
  • Manage an Activity’s background processing without a visible user interface component
Photo of Ken Jones

Ken Jones

Marakana, Inc.

Ken Jones is a Sr. Technical Trainer at Marakana, Inc., specializing in teaching Android programming and other open source technologies. Ken has thousands of in-class hours presenting advanced technical topics, and over 25 years experience in technical training and documentation targeted towards software developers. Ken has delivered training to various software development teams within the Fortune 1000 such as Cisco, Intel, IBM, Boeing, AT&T, Ericsson/Nokia, and many more.

Comments on this page are now closed.


Anguel Stankov
02/02/2012 4:07pm PST

Very good presentation. Unfortunately I think that there is a mistake on page 8. The code snippet should use: if (savedInstanceState == null) instead of if (savedInstanceState != null) This correction means that a new fragment instance will be only created if no bundle with an existing fragment has been passed in.

Regards, Anguel

Chris Hubbard
10/11/2011 9:14am PDT

Excellent overview of fragments, including many helpful real-world gotchas. Slides clearly described the how-tos of implementation. Thanks!

  • HTCpro
  • Microsoft Corporation
  • Open Invention Network
  • X.commerce
  • Black Duck Software
  • BugSense
  • Dolby
  • Intel
  • Make magazine
  • Marvell
  • Meshin
  • MIPS Technologies

Sponsorship Opportunities

For information on becoming a sponsor of Android Open, contact Sharon Cordesse at

Media Partner Opportunities

For media partnerships, contact mediapartners@

Press and Media

For media-related inquiries, contact Maureen Jennings at

Contact Us

View a complete list of Android Open contacts