确定app的系统API level,在mainfest中设置minSdkVersiontargetSdkVersion;对app进行版本控制,在mainfest中设置versionCodeversionName

Supporting Different Platform Versions

Tip:In order to provide the best features and functionality across several Android versions, you should use theAndroid Support Libraryin your app, which allows you to use several recent platform APIs on older versions.

To allow your app to take advantage of these changes and ensure that your app fits the style of each user's device, you should set thetargetSdkVersionvalue to match the latest Android version available.

参考文献:What API level should I target?

Tips:

  • Set android:minSdkVersion to the minimum API level you support.

  • Set android:targetSdkVersion to the highest API level you tested your app on.

  • Do not use android:maxSdkVersion.

  • Set your build target to whatever (I recommend the same as your android:targetSdkVersion), it does not affect the final APK.

  • Wrap calls to new APIs in an if where you check the API level.

  • Test your apps!

<uses-sdk>

<mainfest>

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

integer -- the value of API level

minSdkVersion(Required): the minimum API level. If not set, the default API level is "1".

If the application were to be somehow installed on a platform with a lower API Level(less than the minSdkVersion value), then it would crash at run-time when it tried to access APIs that don't exist. And the app would not be installed if this value is higher than that of hte platform version on the target device.

targetSdkVersion(Recommended): The API level the application is designed to run and it allows the app to use manifest elements or behaviors defined in the target API level. If not set, the integer value equals to minSdkVersion and only the minimum API level is used.

maxSdkVersion(Not recommended): If the API level is greater than this value, the app will not be installed. And after a system update, its value must be equal or greater than the system's API Level interger.

Check System Version at Runtime

private void setUpActionBar() {
// Make sure we're running on Honeycomb or higher to use ActionBar APIs
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ActionBar actionBar = getActionBar();
actionBar
.setDisplayHomeAsUpEnabled(true);
}
}

Note:还可以在XML中使用新版本的attributes,如果版本不支持,低版本的Android仅仅ignore某个attribute。

API Level

某个版本的 Android platform 提供的 framework API revision, through framework API app can interact with underlying Android system.

The framework API consists of:

  • A core set of packages and classes

  • A set of XML elements and attributes for declaring a manifest file

  • A set of XML elements and attributes for declaring and accessing resources

  • A set of Intents

  • A set of permissions that applications can request, as well as permission enforcements included in the system

Android applications are generally forward-compatible with new versions of the Android platform.

Filtering the Reference Documentation by API Level

By default, API Level filtering is disabled, so that you can view the full framework API, regardless of API Level.

To use filtering, select the checkbox to enable filtering, just below the page search box. Then set the "Filter by API Level" control to the same API Level as specified by your application. Notice that APIs introduced in a later API Level are then grayed out and their content is masked, since they would not be accessible to your application.

Filtering by API Level in the documentation does not provide a view of what is new or introduced in each API Level ― it simply provides a way to view the entire API associated with a given API Level, while excluding API elements introduced in later API Levels.

Versioning Your Applications-- Android APP 版本控制

android:versionCode― An integer value that represents the version of the application code, relative to other versions.Applications and publishing services should not display this version value to users.

android:versionName― A string value(<major>.<minor>.<point>) that represents the release version of the application code, as it should be shown to users.Publishing services may extract

theandroid:versionNamevalue for display to users.

eg.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.package.name"
android:versionCode="2"
android:versionName="1.1">
<application android:icon="@drawable/icon" android:label="@string/app_name">
...
</application>
</manifest>


更多相关文章

  1. Android(安卓)输入系统解析 (2)
  2. 关于 AndroidJavaCompile.setDependencyCacheDir 的解决办法
  3. android软件版本升级时,安装新版本后,没有出现安装成功界面或直接
  4. android系统进程重要等级
  5. Android彻底退出程序的多种办法
  6. Android(安卓)生成Release版本时,混淆问题的解决
  7. android常见错误记录--持续更新中
  8. Android退出监听
  9. Android(安卓)7.1 系统 部分功能修改 汇总

随机推荐

  1. android List拖动时背景变化
  2. ubuntu android 源码下载
  3. Android下实现一个手机监控摄像头
  4. 13个对Android开发者有帮助的工具和资源
  5. 命令获取 Eclipse Android(安卓)证书指纹
  6. php、java、android、ios通用的3des+base
  7. PHP验证字符串中是否包含指定字符串
  8. PHP截取指定字符[【前面】和【后面】的内
  9. ModStartCMS Laravel9 模块化建站系统v3.
  10. js留言板