1.1 Application Fundamentals

Source: Internet
Author: User

Android applications are written in Java programming language. The Android SDK tool compiles code sources and data files into an Android package, which is a compressed file with the suffix of .apk. A single. APK file contains all the code, which is used as an application, and this. APK file is used by Android devices to install applications.

Once an application is installed on the device, each application runs in its own secure sandbox:

1. The Android operating system is a multi-user Linux operating system in which each application is a different user.

2. By default, the system identifies each application as a unique Linux User ID (this ID can only be used by the system and is invisible to applications ). The system sets permissions for all files of each application. Therefore, only applications that match the Application User ID can read the application files.

3. Each process has its own Virtual Machine (VM). Therefore, the code of each application runs independently.

4. By default, each application runs in its own Linux Process. When any component of an application needs to be executed, the Android system will run the process, stop the process that is no longer needed, or restore the memory occupied by other applications.

In this way, the Android system implements the principle of least privilege. That is to say, by default, each application can only access the components required to complete its work, without accessing other components. In this way, a very secure environment is created. In such an environment, if an application does not assign permissions to it, it cannot access any content of the system.

Even so, for a program, there are several methods to share data with other applications or obtain data from system services:

1. Two applications can share the same Linux User ID. In this case, the two applications can obtain another folder. To protect system resources, programs with the same user ID can run in the same Linux Process and share the same Virtual Machine (the application should also have the same certificate signature)

2. Applications can also obtain device data by requesting permissions, such as contact information, SMS, storage device (SD card), camera, Bluetooth, and so on. The permissions of all applications are displayed to the user during installation. Only after the user agrees to the permission can the application be installed.

The rest of this document describes how Android applications have basic knowledge in the system:

1. defines the core framework components of the application.

2. Declares the components used by the application and the mainfest file of the required device elements.

3. Resources independent from application code can greatly optimize the performance of your application on various configuration devices.

Application Components

For an Android application, the application component is necessary for building the application. Each component is a different point through which the system can enter your application. For users, not all components are real entry points, but these components are mutually dependent-each component is a unique module, which helps to define the overall behavior of the application.

There are four different types of application components. Each type of component serves with a clear intent and has a clear life cycle, which defines how to create and destroy it.

The following are four types of application components:

Activity

An Activity represents a separate screen on the user interface. For example, an email-related application may have an Activity to display the list of new emails, another Activity to write emails, and another Activity to read emails. Although these activities work together in the mail application to form a complete user experience, each part works independently. For example, another application can start any of the above activities (if the email application permits ). For example, a photo application can start a new email writing application in the email application, so that users can share photos.

An activity class is a Java class that implements the Activity. With the help of Activities developers, you can learn more.

Service

The service is running in the background, and it takes a long time to perform operations, or even to execute remote processes. The service does not provide a user interface. For example, when a user comes to another application, the Service is responsible for playing music in the background, or the service does not lock the interaction between the user and the activity and obtains data from the network. For example, an activity can start a service and enable it to run or bond to the activity for interaction.

A Service is implemented as a Service subclass. In the Services Development Guide, you can learn

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.