What is the effect of using targetSDKVersion in Android?

This is an abstraction from Android docs regarding the targetSDKVersion attribute of the uses-sdk element in the AndroiManifes.xml file.

With this set of attributes, the application says that it can run in older versions (up to minSdkVersion), but has been explicitly tested to work with the version specified here. Specifying this version goal allows the platform to disable compatibility settings that are not required for the target version (which could otherwise be enabled for direct compatibility purposes) or enable new features that are not available to older applications.

Can someone explain what compatibility is in this context, or come up with examples of “compatibility options” that can be turned off?

+4
source share
4 answers

This is mainly useful for declaring that you support and adapt to big jumps from the OS, for example, you can create an application that can run from 1.6 to 3.2, not to mention that the target version is 11 +, and it will work, but in API version 11 and higher, you will work in compatibility mode, where the tablet will be asked if you want to enlarge or enlarge the application to fit the screen.

If you set the target version to 11, the system will understand that you really did something to adapt to this level of the API, so you will not be given the opportunity to scale or increase, instead, it just uses it as if it was created only for 3.0+

+6
source

Newer versions of Android have always added features that cannot be used in compatibility mode. That is, when a device oriented to 2.2 is launched on an Android 3.0 device, the functions will be "backward compatible", but if the target is 3.0 and minSdk version 2.2, which will allow installing on devices with a higher frequency (with backward compatibility), as well Run on 3.0 version with backward compatibility is not included (this is what they mean by direct compatibility).

+2
source

targetSDKVersion

The version you are compiling. If you try to use any new apis, you just get compiler errors, because the compiler will not know what these apis mean.

minSdkVersion

The minimum version of sdk that you support. Any device below this will not see or cannot install your application from the market.

Beware that if you use api from the target sdk, which is not available in lower versions, they will compile but will not work and may lead to your application crashing. For this reason, you will need to create your code with this in mind.

For example, perform type checks

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) ... Use ice cream sandwich apis ... 

to ensure that users who are prior to API 14 are not crashing.

Edit:

List of API changes from version to version http://developer.android.com/sdk/index.html

For example, a review of the new in release 4.0.3: http://developer.android.com/sdk/android-4.0.3.html

And really the real details of this release: http://developer.android.com/sdk/api_diff/15/changes.html

+2
source

You can define another targetSDKVersion from minSdkVersion, which actually means that you can use the SDK functions from targetSDKVersion, at the same time you have backward compatibility.

This can be considered as part of the code of your application (for example, integrate C2DM into the application and provide your application even to devices with Android 2.1, but without C2DM support) or in the manifest (for example, the installation parameter for auto, which will be for android 2.1).

Hope this helps!

0
source

Source: https://habr.com/ru/post/1386769/


All Articles