Specifying Your Applications System API Requirements

If your application requires a specific minimum version of the Android platform, or is designed only to support a certain range of Android platform versions, you can specify those version requirements as API Level identifiers in the application's manifest file. Doing so ensures that your application can only be installed on devices that are running a compatible version of the Android system.

To specify API Level requirements, add a <uses-sdk> element in the application's manifest, with one or more of these attributes:

• android:minSdkVersion — The minimum version of the Android platform on which the application will run, specified by the platform's API Level identifier.

• android:maxSdkVersion — The maximum version of the Android platform on which the application is designed to run, specified by the platform's API Level identifier.

When preparing to install your application, the system checks the value of this attribute and compares it to the system version. If the android:minSdkVersion value is greater than the system version, the system aborts the installation of the application. Similarly, the system installs your application only if its android:maxSdkVersion is compatible with the platform version.

If you do not specify these attributes in your manifest, the system assumes that your application is compatible with all platform versions, with no maximum API Level.

To specify a minimum platform version for your application, add a <uses-sdk> element as a child of <manifest>, then define the android:minSdkVersion as an attribute.

<?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>

For more information, see the <uses-

sdk> manifest element documentation and the API Levels document.

0 0

Post a comment