Android versions are shipped out very frequently. With every latest version of Android, you get new features and new improvements. Though Google tries very hard to provide backward compatibility, they aren't able to do so always. For example, there is no backward compatibility for Material design components; you need to be targeting API levels greater than 21 in order to use them. This requires the developer to check beforehand whether the component is supported on that API level or not to ensure that your app runs smoothly on all levels. We usually do that as follows:
if(Build.VERSION.SDK_INT>Build.VERSION_CODES.JELLY_BEAN){ }
Anko provides helper functions that help us achieve similar things but with easier syntax. In this recipe, we will see how to use it.
I'll be using Android Studio to write code. You also need to include the Anko library by adding these lines to your build.gradle
file:
compile "org.jetbrains.anko:anko:$anko_version"