Android配置文件中标签

SYNTAX:

    <uses-sdk android:minSdkVersion="integer" android:targetSdkVersion="integer" android:maxSdkVersion="integer" />

ATTRIBUTES:
android:minSdkVersion

An integer designating the minimum API Level required for the application to run. The Android system will prevent the user from installing the application if the system’s API Level is lower than the value specified in this attribute. You should always declare this attribute. If you do not declare this attribute, the system assumes a default value of “1”, which indicates that your application is compatible with all versions of Android.
是一个标示该应用可以运行的最小API级别。也就是说,如果想把这个应用安装到某个Android系统中,而如果该Android系统的API级别比这个参数小,那该Android系统就不会允许你安装成功这个应用。所以,你开发的时候,应该指定好这个属性,免得到时候你的应用在某低版本Android系统中使用高版本API的时候,应用就崩溃了。若不设置,则默认为“1”,即可以在任何API级别的Android系统上运行。

android:targetSdkVersion

An integer designating the API Level that the application targets. If not set, the default value equals that given to minSdkVersion.
targetSdkVersion意味着你 该应用最想在哪个API版本上运行。若不设置,则默认等于minSdkVersion这个参数关于到你代码的API级别与运行时的系统的级别之间的商量权衡问题

这篇文章举例说明了minSdkVersiontargetSdkVersion之间的关系。如图:
Android配置文件中<uses-sdk>标签_第1张图片

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.

关于各个设备的兼容性问题:
Device Compatibility。
Android配置文件中<uses-sdk>标签_第2张图片
另外还有:

只要 APK 的 targetSdkVersion 不变,即使这个 APK 安装在新 Android 系统上,其行为还是保持老的系统上的行为,这样就保证了系统对老应用的前向兼容性。

所以,我们可以猜测到,如果 Android 系统升级,发生这种兼容行为的变化时,一般都会在原来的保存新旧两种逻辑,并通过 if-else 方法来判断执行哪种逻辑。果然,在源码中搜索,我们会发现不少类似 getApplicationInfo().targetSdkVersion < Buid.XXXX 这样的代码。
来自这篇文章。

To make your activity look like a dialog box:
Android配置文件中<uses-sdk>标签_第3张图片
To make your activity has a transparent background:
Android配置文件中<uses-sdk>标签_第4张图片

最后附上Android 5.0的API
Android 5.0 API

你可能感兴趣的:(android)