Android Application Framework

Source: Internet
Author: User

 

Once an android Application is loaded into a device, each program runs in its own secure sandbox.

1. The android operating system is a multi-user linux system, and each application is a user.

2. by default, the system will assign a unique linux User id to each app (this id will only be used by the system and will only be known by this app ), the system sets permissions for all files in each app. Only programs assigned the app user ID can access the app.

3. Each process has its own VM. The code of an app is isolated from other processes.

4. By default, each app runs in its own liunx process. When any component of the app needs to be executed, android will enable the process. When it is not needed or the system must restore memory for other apps, the process will be closed.

Android uses this method to implement the principle of least privilege. That is: by default, each app can only access the controls it needs to work without additional controls. In this way, a very secure environment is created: the app cannot access other unauthorized parts of the system.

However, some methods can be used to share data with other apps and access system services:

1. it is okay to arrange two apps to share the same linux User ID. In this case, they can access their files. To maintain system resources, apps with the same userID can run and share a VM in a linux Process (the application must use the same certificate ).

2. An app can request permissions to access device data, such as user contacts and text messages. All app permissions must be confirmed by the user when the app is installed.

The above explains the basic information of the app in the system. The remaining content of this document is as follows:

1. Core framework components defined in your app.

2. manifest file that declares components and requires device features.

3. The resources separated from your app Code allow your program to elegantly optimize the configuration of various devices for its behavior.

APP Components

App components are basic for android applications

Activities, Services (long run in the next day or work for remote processes), ContentPrivider, Broadcast explorer.

When the system starts a component, the system starts a process for the app (if not run) and instantiates the class required by the component, for example: when your app wants to get photos through system photography, the activity that runs in the process belongs to the Camera app rather than your app. Therefore, Android applications do not have an entry point (for example, main ()).

Activated Components

Manifest File

Before the android system starts a component, the system must know that the component exists when reading the manifest file. Your app must declare all components in the file that exists in the root directory of the app project.

Declare component capabilities

For example, if you want to create an email application, you can declare an intent filter to respond to the send intent as follows:

 

 
      ...                        
                                  
                   
                
    
              
 
Then, if another app creates an intent carrying ACTION_SEND and transmits it to startActivity (), the system may start your activity, so that you can drag and drop and send emails.

 

Declare app requirements

To protect your applications from being installed on devices that lack the features required by your apps, it is very important to explicitly declare the device on which your application can be installed in the manifest file. Most information systems do not read data, but external devices such as Google play provide filtering for users who search for apps from their devices.

For example, if your application requires a camera and Android2.1, you should declare in your manifest file as follows:

 

     
      
   
        ...
   
  
 
At this time, devices without cameras and Android versions earlier than 2.1 cannot install your applications from Googleplay.

 

However, when your application uses camera but does not have to own a Camera, you shouldThis attribute of required is set to false, and is determined at runtime by camera to properly disable any camera features.

App Resources

One important aspect of providing resources from the code is that you can provide optional resources for different device configurations. For example, to define UI Strings in xml, you can translate the text into different languages and save it to the separated files.

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.