Android配置文件中<uses-sdk>标签

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之间的关系。如图:
这里写图片描述

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
这里写图片描述
另外还有:

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

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

To make your activity look like a dialog box:
这里写图片描述
To make your activity has a transparent background:
这里写图片描述

最后附上Android 5.0的API
Android 5.0 API

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值