targetSdkVersion究竟是什么?

时间:2017-06-19 13:33:52

标签: android

我知道targetSdkVersion是最高版本的SDK版本,您的应用程序可以与#34;一起使用,但有什么意义呢?我设置了targetSdkVersion 22,我的应用程序在api 25设备上正常运行。它不是要防止在更进一步的api版本上安装吗?如果不是,那么它的含义是什么?

2 个答案:

答案 0 :(得分:3)

android:targetSdkVersion 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).

As Android evolves with each new version, some behaviors and even appearances might change. However, if the API level of the platform is higher than the version declared by your app's targetSdkVersion, the system may enable compatibility behaviors to ensure that your app continues to work the way you expect. You can disable such compatibility behaviors by specifying targetSdkVersion to match the API level of the platform on which it's running. For example, setting this value to "11" or higher allows the system to apply a new default theme (Holo) to your app when running on Android 3.0 or higher and also disables screen compatibility mode when running on larger screens (because support for API level 11 implicitly supports larger screens).

There are many compatibility behaviors that the system may enable based on the value you set for this attribute. Several of these behaviors are described by the corresponding platform versions in the Build.VERSION_CODES reference.

To maintain your application along with each Android release, you should increase the value of this attribute to match the latest API level, then thoroughly test your application on the corresponding platform version.

Introduced in: API Level 4

Sorry for just posting straight from Android.com but it gives a clear signal of what it does.

答案 1 :(得分:0)

这是你正在开发的那个。应用程序也可以在更高的API上运行。但它是用于渲染布局等的那个。