The main components of the Android program and the Manifest file

Source: Internet
Author: User
Tags home screen

Android main components of the program and the Manifest file

Android consists of loosely-coupled components and binds togetherusing Manifest, and Manifest describes the interactions between each component and them, as well as the metadata of the application, its hardware and platform requirements, External libraries and the required permissions.

The following components provide the basic architecture module for your application:

Activity : mainly used to interact with the user, display interface, is the Android program's presentation layer

Service :Android 's behind-the-scenes workers, invisible, unable to interact, can update data sources and Activity, trigger notifications and broadcast Intent.

Content Provider : As the name implies, the contents provider is to provide data to other applications. Used to manage and persist application data, often interacting with SQL data.

Intent : Powerful to unimaginable characters,Android almost always applies it, he is a powerful messaging framework between applications. He can be used to start stopping activity and Service, and to live within the system to target activity. Service or broadcastreceiver broadcast messages, and requests to perform operations on a particular piece of data.

Broadcast Receiver :Intent Listener. broadcast Receiver enables applications to listen to Intent broadcasts that match a specified filter . broadcast Receiver automatically launches the application to respond to a received Intent, which makes them the best choice for event-driven applications.

Widget : A visual application component that is typically added to the home screen of a device. Widgets are a special variant of broadcast Receiver that can be used to create dynamic interactive application controls. Users can add these components to the home screen.

Manifest Introduction

each Android projects contain a Manifest file ------Android manifest.xml, which is stored at the bottom of the project hierarchy. The Manifest file defines the structure and metadata of the application and its build and requirements.

it contains one of the meters that make up the application Activity,Service,Content Provider, and broadcast Receiver nodes. and use Intent Filter and permissions to determine how these components interact with each other and with other applications.

The Manifest file can also specify metadata for the application (such as its icon, version number, or subject) and an additional top-level node that can be used to specify required security permissions and unit tests, as well as to define hardware, screen, and platform support.

The Manifest file consists of a tag with a Manifest label with a package attribute that is set as the project name . It usually contains a xmlns:android property to provide some system properties that are used within the file.

Here are a few Manifest Several nodes and attributes:

Several properties under the <manifest> root node

Versioncode: Defines the current application version as an integer. This number is incremented for each iteration of the version.

Versionname: You can define a public version number that is displayed to the user.

InstallLocation: Specifies the preferred location for program installation. Property value:internalonly ( installed on internal storage only ). preferexternal ( install to an external memory card whenever possible ) . Auto ( requires system stability, then select installation Location )

Sub-node tags under the manifest node:

1.USES-SDK : For defining the correct installation, you must specify the highest version (maxsdkversion), minimum version (minsdkversion), and the target version of the program design ( Targetsdkversion).

2.uses-configuation: Specifies a combination of each input mechanism supported by the application, which generally does not need to include this node, and is useful for games that require special input control to specify any combination of the following input devices:

android:reqtouchscreen : Choose One of Notouch,stylus,finger or undefined , To specify the required touch screen input.

android:reqkeyboardtype : Specifies the keyboard type as oneof the Nokeys, Qwerty,Twelevekey, or undefined.

         android:reqhardkeyboard : Set to true

if the application requires a hardware keyboard

         android:reqnavigation nonav , dapad , trackball , wheel or undefined One of the necessary navigational devices.

android:reqfivewaynav : set to True if the input device is required to be able to navigate up, down, left and right, and be able to machine the current option . This includes tracking the ball and D-pad

3.uses-feature: Specifies each hardware feature that the application requires. You can avoid installing the application on a device that does not contain the necessary hardware features.

take NFC for example:

<uses-feature android:name="ANDROID.HARDWARE.NFC" />

4. for a complete list of hardware, see http://developer.android.com/guide/topics/manifest/uses-feature-element.html

5.Supports-screens is used to specify which screens are designed and tested for the program. When a program supports a device's screen, it is typically laid out using the Zoom attribute in the layout file provided by the developer. When running on an unsupported device, the system may apply compatibility mode to display applications such as pixel scaling, and creating an extensible layout to accommodate all screen sizes is a best practice.

Where the properties are

<Supports-screens

android:smallscreens = "true"

resolution than the traditional HVGA A small screen, usually a QVGA Screen

android:normalscreens = "true"

Specify a typical phone screen, at least HVGA, include WVGA and the WQVGA

android:largescreens = "true"

Larger screen than the normal screen, where the large screen is considered much larger than the phone's display

android:xlargescreens = "true"

A larger screen than an ordinary big screen, usually a screen of a tablet screen

in the Honeycomb MR2 (API level) additional attributes are introduced, and a more granular control program layout can support the size of the screen. If the program supports devices running the previous version of the API level, the most important thing is to use these extra attributes in conjunction with earlier attributes .

android:requiressmallestwidthdp="480"

allows device-independent pixels to specify the minimum supported screen width (the smaller of the value screen height and width), which is used to Google Play Store on filtering the apps that don't know their screen, So You should specify to provide an acceptable user experience when you use it. The minimum number of absolute pixels required for the layout.

ANDROID:COMPATIBLEWIDTHLIMITDP = "All"

Specifies an upper limit that may not be extended by the application after this value is exceeded. Use this property to enable the system to start compatibility mode on a device with a screen resolution greater than the value you specify.

android:largestwidthlimitdp="720"

Specify an absolute limit, beyond which the program will not be able to pinch the extension. Typically, on a device with a screen resolution greater than the value you specify, this causes the system to force the application to run in compatibility mode (and the user cannot disable this mode)

Forcing the application to enter compatibility mode is considered a bad user experience and, whenever possible, should allow the layout to scale appropriately so that it can be used on larger devices.

/>

6.support-gl-texture: used to declare a program capable of a specific compression of the GL Texture format of liberal arts resources. If your program can support multiple texture compression formats, you must use multiple support-gl-texture elements. If you want to know more, you can see http://developer.android.com/guide/topics/manifest/supports-gl-texture-element.html

7.uses-permission as part of the security model, it declares the needs of the application. When the program is installed, the permissions that are set are all told to the user, and they decide whether to agree or not, and many APIs are services that must declare permissions, especially billing and security issues.

example: < uses-permission android:name " Android.permission.ACCESS_FINE_LOCATION " />

8.permission: Application components can create permissions to restrict access to shared applications. You can customize the permissions or use the existing system.

9.Instrument: A test framework provided by the Instrument class to test application components while the test application is running.

10. Span style= "font-family: ' Courier New '" >application:  Manifest can contain only one application node. It uses various properties to specify the individual metadata for the application (including icons, headings, themes, etc.), which is typically set at development time as true debugable

uses-library: used to specify the shared library that the application needs. For example, the map API is packaged as a standalone library, which is not an automatic link. You can specify whether a package is required or optional. Specifies that the application cannot be installed on a missing specified device when required, and when specified as optional, the application must use a reflection mechanism to check for the existence of the library before using it.

Example: <uses-library android:name="com.google.android.maps"                           android:required="false"/>


The main components of the Android program and the Manifest file

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.