What is compatibility behaviours in android?

239 Views Asked by At

While I was reading documentation of targetSDKVersion, I have come through a term i.e. "Compatibility behaviours".

An integer designating the API Level that the application targets. If not set, the default value equals that given to minSdkVersion. This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version. The application is still able to run on older versions (down to minSdkVersion).

I don't understand, what is compatibility behaviour here. Any example would help me to make this term clear.

1

There are 1 best solutions below

0
On

This mean, for targetSDKVersion and higher API, the code will run as it. for minSdk to targetSDKVersion-1, backward compatibility translations/behaviors could be done by the system.

Exemple:

targetSdkVersion 21 // <= Lollipop 5.x 
minSdkVersion 17 // 4.4 KitKat <= you support this version thanks to some compability behaviors (it's done by the system so you don't have to woory)

If your app run on Android 6.0 (Marshmallow) API 23, since you support API/SDK 21, your app will run on Android 6.0 without any compability behaviors.

Detail about API Behavioral Compatibility can be found here (page 14) : http://static.googleusercontent.com/media/source.android.com/en//compatibility/android-cdd.pdf

Basically it means, if you call a function whatever the API version the behaviour should be the same. It is specially the case when you release new API, you generally extend, modify, fix code, that could not align with the previous version behaviour. So to prevent any issue due to code update, Android provide a compatibility behaviour layer that guarantee the same behaviour.