Android device compatibility

Source: Internet
Author: User

 

Android is designed to run on a variety of devices. To achieve this, android provides a dynamic app framework, in this framework, you can provide specific configuration resources in dynamic files (different xml layout files with different screen sizes). android will load the appropriate resources according to the device configuration.

What does compatibility mean?

There are two different adaptations: Device adaptation and app adaptation.

Device compatibility: applications can run normally in the android execution environment.

As an app developer, you do not need to be compatible with a device. However, you must consider app adaptation under such a potential device configuration.

Make your application available to devices

Some features are based on hardware, such as the compass sensor, some are based on software, but not app widgets, and some are based on the platform version.

In order to achieve the largest user group of your application, you should try to use an apk to support the more devices, the better. In many cases, you should disable the optional features at runtime to provide alternatives to application resources for different configurations (for example, providing different layout files for different screen sizes ), if necessary, use the following features of Google play to limit the availability of your applications:

1. device features

2. Platform version

3. Screen Configuration

Device features

To allow you to properly manage your app Based on device features, android defines featuresIds. For example, the featureid of the compass sensor isFEATURE_SENSOR_COMPASSThe feature id of app widgets isFEATURE_APP_WIDGETS.

If necessary, you can install your app but their devices are not provided in your manifest file. Declared feature user.

For example, your app will not work on a device that lacks a compass sensor. You can declare a compass sensor in your manifest file as follows:

 

     
  
       ...
  
 
The Google play Store compares the feature declared by your app with the feature on your device to determine whether your app is compatible with each application. If the device does not provide all the features required by your app, you cannot install your app.

 

However, if your app does not require a device feature, you need to set the required attribute to false and detect the device feature when the device is running, if your app feature is unavailable on the current device, you need to gracefully degrade the app feature. For example, you can call hasSystemFeature () to check whether a feature is available:

 

PackageManager pm = getPackageManager();if (!pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_COMPASS)) {    // This device does not have a compass, turn off the compass feature    disableCompassFeature();}

 

Platform version

For example, the Calendar Provider API is added after API level 14. If your app must use this api, you can declare that the minimum version you support is 14:

 

     
  
       ...
  
 
targetSdkVersionIt is important because it implies whether your app inherits the behavior changes in the new version. If you do not Update targetSdkVersion to the latest version. The system assumes that when running the latest version of sdk, what your app needs is previously compatible.

 

If your app uses APIs added in the latest sdk version but does not use them as the main function, you should check the api levels at runtime, at the same time, when the API level is too low, the feature is elegantly reduced. in this case, the minimum APIlevel that supports your app operation is assignedMinSdkVersion, and then compare the current system versionSDK_INT is compared with the api version you want to check. For example:

 

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {    // Running on something older than API level 11, so disable    // the drag/drop features that use ClipboardManager APIs    disableDragAndDrop();}
Screen Configuration

 

To classify devices by their 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 density. The system makes appropriate adjustments to your UI layout and image resources for each screen, however, you should optimize the user experience by adding special la s for screens of different sizes and optimizing bitmap images for normal screen density.

Control application availability for commercial reasons

You should restrict the availability of your app for commercial or legal reasons. It is not as good as an application that shows the London Underground carriage list cannot be used outside the UK. For this type of situation, google play provides filtering options on the developer console to allow you to control non-technical availability of your application, such as the user location.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.