Original address: http://developer.android.com/guide/practices/compatibility.html
Android is designed to work on a variety of different devices, and for this purpose, Android provides a dynamic app framework in which you can provide specific configuration resources in dynamic files (different XML layout files for different screen sizes). Android will load the appropriate resources based on the device configuration.
What does compatibility mean?
There are two different adaptations: device adaptation and app adaptation.
Device compatibility: The ability to run the application properly in an Android execution environment.
As an app developer, you don't need a device that is device compatible. But you have to consider the app adaptation in such a potential device configuration.
Make your app available to your device
Some features are hardware-based, such as compass sensors, some are software-based rather than app widgets, and some are platform-based versions.
In order to achieve the largest user base of your application, you should try to use an APK to support the more device configuration the better. In many cases, you should disable optional features at run time, provide alternatives to application resources for different configurations (such as providing different layout files for different screen sizes), and if necessary, you need to limit the availability of your application through the following features of Google Play:
1, device characteristics
2. Platform version
3. Screen configuration
Device features
In order to allow you to manage your app,android based on the appropriate device features, the featuresids is defined, for example, the Featureid of the Compass sensor is feature_sensor_compass   the feature ID of the app widgets is feature_app_widgets
If necessary, you can protect the installation of your app but their device is not available in your manifest file with <USES-FEATURE> declared feature user
For example, your app won't work on a device that lacks a compass sensor, so you can declare a Compass sensor in your manifest file:
<manifest ... > <uses-feature Android:name="Android.hardware.sensor.compass" android:required="true" /> ...</manifest>
The Google Play Store compares the feature of your app and the feature on the user's device to determine if your app is compatible with each app. If the device doesn't provide all the feature your app needs, the user won't be able to install your app.
However, if the main role of your app does not require a device feature, you need to set the required property to false and detect the device feature when the device is running, if your app feature is not available on the current device, you need an elegant Degradation app feature , for example, you can query whether a feature is available by calling Hassystemfeature () like this:
Packagemanagerpm=Getpackagemanager();if (!pm.hassystemfeature(Packagemanager.Feature_sensor_compass)) { //This device does does have a compass, turn off the compass featuredisablecompassfeature();}
Platform version
For example , the Calendar Provider API is added after API level 14, and if your app must use this API, you can declare that the minimum version number you support is:
<manifest ... > <USES-SDK android:minsdkversion="+" android:targetsdkversion="very" /> ...</manifest>
targetSdkVersionis important because it implies that the system your app inherits behavior changes in the new version, if you don't
targetSdkVersion更新到最新版本,这时系统假设在运行最新版本sdk时,你的app需要的是先前兼容的行为。
Code style= "Color:inherit; Text-decoration:none; Font-family:roboto,sans-serif; Background-color:rgb (249,249,249) ">minsdkversion, Then compare the current system version sdk_int is compared to the API version that you want to check for compliance. For example:
if (Build.VERSION.Sdk_int< Build.Version_codes.Honeycomb) { //Running on something older than API level one, so disable //The Drag/drop features that useClipboardManagerAPIsDisabledraganddrop();}
Screen Configuration
To classify devices by Device screen type, Android defines two features for each device: Screen size (small, normal, large, and XLarge) and screen density (mdpi (Medium), hdpi ( HDPI), xhdpi (Extra high), xxhdpi (Extra-extra High), and others.).
By default your app is compatible with all sizes and densities, and the system makes the right adjustments to your UI layout and image resources for each screen, but you should optimize the user experience by adding special layouts for different sizes of screens and optimizing bitmap images for normal screen density.
for business reasons, Control of the application Availability of
You should limit the usability of your app for business or legal reasons, as an application that shows a London Underground train cannot be used outside of the UK, for this type of situation, Google play provides filtering options in the developer console to allow you to control the non-technical usability of your app, such as user location.