2nd Android App (1th speaking)

Source: Internet
Author: User
Tags comparison table android sdk manager

2.1 Understanding the Android operating system

Android was originally founded by Andy Robin (Andy Rubin) and was acquired by Google in 2007, and Google has made a huge success on smartphones with its Android operating system.

1, the characteristics of the Android operating system

The Android operating system is a multi-user Linux system, and each application is a standalone user. The system assigns a unique Linux user ID to each application by default (this ID is only used by the system and is unknown to the application). The system sets permissions for all files of an application, so only the user ID assigned to the application can access them.

Each process has its host virtual machine (VM), so the code for one application runs independently of other applications.

By default, each application runs in its own Linux process. Android will start this process when any component of an application needs to be called. The process is then closed when no component is called or when the system needs to reclaim memory for other applications.

In this way, the Android system implements the least privileged principle. That is, each application can only invoke the work components it needs by default. This creates a very secure environment in which an application cannot access parts of the system that are not granted its permissions.

Nonetheless, there are many ways to share data with an application and other applications, or to have an application invoke system services:

    • It is possible to assign the same Linux user ID to two applications so that they can access each other's files. To conserve system resources, applications that have the same user ID can also be run on the same Linux process and share VMS (must be signed with the same certificate).
    • Applications can access device data by requesting permissions, such as contacts, SMS messages, pluggable storage (SD cards), cameras, Bluetooth 、...... Wait a minute. All application permissions must be granted by the user at the time of installation.

2. How Android programs exist in the system

When developing an application running on an Android operating system, the Android SDK tool compiles the code and packs any data into an Android package with the associated resources, which is actually a compressed file with an. apk suffix. All the code in an. apk file is an Android application.

Installing an application on an Android device is installing the. apk file.

Once the installation is successful, the Android program has its own running sandbox (a sandbox is a way to run an application in a restricted security environment to restrict the code access granted to the application).

2.2 Understanding Android SDK and API version

Each Android version has a unique integer identifier called the API level. Because users use programs that are always older than the latest published API versions, the actual Android application must ensure that it can work in a multi-version API environment.

1. Android SDK and project configuration

The Android SDK provides us with a collection of API link libraries and development tools for building, testing and debugging Android apps. Before specifying the Android API version configuration, make sure that you have installed the corresponding version of the Android SDK with Android SDK manager.

Each Android application must be properly configured with the API level used, with three types:

    • Target framework– which framework to use to create the application (compiled).
    • Minimum Android version– Specifies the minimum version (running) that Android apps can use.
    • Target Android version– Specifies the version (running) that the Android application tries to use.

By default, three APIs are set to the same value:

Change the Target framework to an API version to have all of the API features for that version. If you want to be compatible with earlier versions of Android, you can modify the "Minimum Android to target" option:

The options in the development of Android app can be installed on Android 4.0.3 to Android 5.0 on all versions of the phone, ie API 15~api 21. However, although it can be installed on these platforms, it does not guarantee that the application will function properly on those platforms. For example, if you install a program on the Android 4.0.3 (API 15) platform, but the code calls a higher API than API 15, then the program will not work properly on the Android 4.0.3 platform. Therefore, in this case, you must explicitly include a run-time check:

if (Android.OS.Build.Version.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)

{

Builder. Setcategory (Notification.categoryemail);

}

(Note: Android.OS.BuildVersionCodes.Lollipop refers to Android 5.0)

2. Android API version Comparison table

The following table lists the various Android versions and their corresponding information:

As you can see from the table, Android versions are released very frequently, and sometimes several versions are released in a year. How do you make sure that your application can still run reliably in so many versions? This is the role of API level.

3. API level and custom libraries

When you create an Android libraries project, you should allow the library functions you develop to apply to various versions of the API, so you generally do not need to set the lowest level of APIs and the highest levels of APIs, but should follow these best practices:

    • When referencing a version of the API, make sure that the application runs at a version of the API that is not less than the referenced version.
    • When designing custom library functions for other Android applications, set the minimum API level required for the application.

In summary, make sure that the library functions you develop use as few APIs as possible to make the library you are designing a broader application.

2nd Android App (1th speaking)

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.