Android Version Checking
You can include features from later versions of the Android SDK by doing a comparison of the current build versions. You compare whether the internal constant Build.VERSION.SDK_INT
is greater than or equal to the version of the target feature, as shown in Listing 11.10. If the code is run on a device having an earlier version of the Android SDK, the code will be skipped. For example, to display a home indication in the action bar, you need Android 3.0 or Honeycomb or later, because that was when the ActionBar
feature was introduced.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)private void setupActionBar() { if (Build.VERSION. ...
Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications 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.