Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Fragmentation

Android Fragmentation

A brief talk given at MinneBar 2013 about the basics of battling fragmentation on Android.

Daniel Lew

April 06, 2013
Tweet

More Decks by Daniel Lew

Other Decks in Programming

Transcript

  1. Problem • There too many phones! • Afraid to enter

    the Android arena? • There are solutions to most problems! Sunday, November 24, 13
  2. Screen Break Points • Determine when to switch from one

    layout to another • Can break on fragments or custom views. Sunday, November 24, 13
  3. Custom Views • Collection of standard Views, wrapped in a

    custom View • Customize for each configuration Sunday, November 24, 13
  4. Reflection • Standard Java reflection • Only run code if

    the Class/Method exists Sunday, November 24, 13
  5. Branched Code • Build.VERSION.SDK_INT if (Build.VERSION.SDK_INT >=9) // Run code

    only available on API 9+ • Android 2.2+ does not cause VerifyErrors if unavailable classes/methods are never run. Sunday, November 24, 13
  6. Proxy Classes • Create a class that encapsulates switched code

    • Class uses either reflection or branching • Access class without caring about which version of Android you are running Sunday, November 24, 13
  7. Android Support Library • Google provided library • Supports Fragments,

    LoaderManager, Notifications, Sharing • Includes classes not in vanilla Android (Pagers) • http://developer.android.com/tools/extras/ support-library.html Sunday, November 24, 13
  8. NineOldAndroids • Backwards-compatible property animation library • All old animations

    aren't performant, but better than nothing. • http://nineoldandroids.com/ Sunday, November 24, 13
  9. HoloEverywhere • Consistent theming across devices • https://github.com/Prototik/ HoloEverywhere •

    If you don't want a library, import from Android Open Source Project itself. Sunday, November 24, 13
  10. Resource Qualifiers • All files under /res/ are resources •

    Format: /res/<type>- <qualifier>/ • Qualifiers can be applied to any resource Sunday, November 24, 13
  11. Useful Resource Qualifiers • Orientation • -landscape, -portrait • Screen

    size • -small, -medium, -large, -xlarge • -sw600dp, -sh900dp, etc. • Platform • -v11, -v14, etc. Sunday, November 24, 13
  12. What to Qualify • Layouts • Dimensions (and integers) •

    Booleans • Styles and themes Sunday, November 24, 13