0

I'm beginning to dive into Android, having been an iOS developer for a while, and I find the obsession with backwards compatibility a bit confusing. In particular, I can't seem to understand why the official docs mention compat/support classes instead of proper ones -- for example, android.support.v4.view.ViewPager.

I understand backwards compatibility, but I have always seen it as a kind of thing you do if you have no other choice. I also well understand that Android and iOS have wildly different approaches to backwards compatibility, and for good reasons.

So, my question is: are there classes that only exist as compat/support? And what if I didn't care for bw-compat and wanted to do stuff as if Lollipop (or Marshmallow, or Nougat) was the first version of Android ever? In particular, I'm running into troubles with the PreferenceFragment thing that doesn't properly exist in support.

Morpheu5
  • 2,610
  • 6
  • 39
  • 72

1 Answers1

2

To answer one of your questions: Some classes only exist in compact/support packages and are not added to the SDK.

ViewPager for example, you can check out these threads for a detailed explanation https://stackoverflow.com/a/21284814/1865583 https://stackoverflow.com/a/9958041/1865583

And if may quote @CommonsWare from the above posts: "The Android Support package is not only for backports of newer APIs. It is also for other classes that, for whatever reason, are not being added to the SDK, such as ViewPager and its supporting classes."

Community
  • 1
  • 1
JanBo
  • 2,925
  • 3
  • 23
  • 32
  • Thanks. And, is there any way of telling if there is a non-support version of any given class? – Morpheu5 Sep 28 '16 at 12:09
  • 1
    I usually pay attention to the given class package name when importing it through the code editor. That way you can see if it has alternatives in non support packages...also you will get the hang of it as you spend more time with Android. – JanBo Sep 28 '16 at 12:15