【文章內(nèi)容簡介】
API revision that they require It lets the system negotiate the installation of applications on the user39。s device, such that versioninpatible applications are not installed.Each Android platform version stores its API Level identifier internally, in the Android system itself.Applications can use a manifest element provided by the framework API —usessdk— to describe the minimum and maximum API Levels under which they are able to run, as well as the preferred API Level that they are designed to support. The element offers three key attributes: android:minSdkVersion— Specifies the minimum API Level on which the application is able to run. The default value is 1. android:targetSdkVersion— Specifies the API Level on which the application is designed to run. In some cases, this allows the application to use manifest elements or behaviors defined in the target API Level, rather than being restricted to using only those defined for the minimum API Level. android:maxSdkVersion— Specifies the maximum API Level on which the application is able to run.Important:Please read theusessdkdocumentation before using this attribute.For example, to specify the minimum system API Level that an application requires in order to run, the application would include in its manifest ausessdkelement with aandroid:minSdkVersionattribute. The value ofandroid:minSdkVersionwould be the integer corresponding to the API Level of the earliest version of the Android platform under which the application can run.When the user attempts to install an application, or when revalidating an appplication after a system update, the Android system first checks theusessdkattributes in the application39。s manifest and pares the values against its own internal API Level. The system allows the installation to begin only if these conditions are met: If aandroid:minSdkVersionattribute is declared, its value must be less than or equal to the system39。s API Level integer. If not declared, the system assumes that the application requires API Level 1. If aandroid:maxSdkVersionattribute is declared, its value must be equal to or greater than the system39。s API Level integer. If not declared, the system assumes that the application has no maximum API Level. Please read theusessdkdocumentation for more information about how the system handles this attribute.When declared in an application39。s manifest, ausessdkelement might look like this:manifest usessdk android:minSdkVersion=5 / .../manifestThe principal reason that an application would declare an API Level inandroid:minSdkVersionis to tell the Android system that it is using APIs that wereintroducedin the API Level specified. If the application were to be somehow installed on a platform with a lower API Level, then it would crash at runtime when it tried to access APIs that don39。t exist. The system prevents such an oute by not allowing the application to be installed if the lowest API Level it requires is higher than that of the platform version on the target device.For example, thepackage was introduced with API Level 3. If an application uses that API, it must declare aandroid:minSdkVersionattribute with a value of 3. The application will then be installable on platforms such as Android (API Level 3) and Android (API Level 4), but not on the Android (API Level 2) and Android platforms (API Level 1).For more information about how to specify an application39。s API Level requirements, see theusessdksection of the manifest file documentation.Development ConsiderationsThe sections below provide information related to API level that you should consider when developing your application.Application forward patibilityAndroid applications are generally forwardpatible with new versions of the Android platform.Because almost all changes to the framework API are additive, an Android application developed using any given version of the API (as specified by its API Level) is forwardpatible with later versions of the Android platfo