Yes, you can check for the version constants.
In general, for handling incompatibility of some API functions it is common to use the constant Build.VERSION.SDK_INT
, which has the information of which version the device is running.
And along with the values of the SDKs, available in the class Build.VERSION_CODES
you can execute code condition the version in which the application will run.
An example would be:
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ViewPropertyAnimator vpa = view.animate();
// Restante do código usando ViewPropertyAnimator
} else {
Animation an = new AlphaAnimation(0f, 1f);
// Restante do código usando a API View Animation
}
This code will not work for devices with a smaller version than SDK 4 (Android 1.6 Donut), these constants have been added in this release.