Compatibility: Fallback or Duplicate?

In this chapter, you have used a compatibility strategy known as graceful fallback. Graceful fallback means that your app will use new features and code when run on newer platforms and fall back to using older features on older ones. You did this by checking the SDK version at runtime.

Graceful fallback is not the only strategy. Instead of falling back on older platforms, you can use an identical feature that mimics the features of newer platforms. We call this strategy duplication. Duplication strategies fall into two groups: duplication-on-demand and duplicate replacement. In duplication-on-demand, you use the replacement only on older platforms where the real thing is unavailable. Duplicate replacement ...

Get Android Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.