Introduction to Android System development

Source: Internet
Author: User

Android OS

Android is a Linux-based operating system that uses Java as a program interface.

He provides tools such as compilers, debuggers, and his own emulator (Dvm-dalvik Virtual machine).

Android was developed by Google-led Open Handset Alliance.

Android uses a virtual machine that is more specific. Dalvik used a few special methods. You can't run a normal Java program on Android.

Android provides a DX tool to convert ordinary Java class files to Dex (Dalvik executable) files.

The Android program is finally packaged into an. apk file via the AAPT (Android Asset packaging Tool) program.

ADT under Eclipse can automatically convert class to Dex and then package it as an APK file when it is released.

Android supports the 2D and 3D OpenGL graphics library and supports SQLite database.

Each Android program runs in a separate space allocated by the Android system, so every program does not affect and destroy other programs, which is very safe.

some of the important Android components

An Android program consists of the following sections.

    • Activity: Represents the presentation layer of the Android program, such as the user-seen interface. An Android program may have several activities that can be switched during the program's operation.
    • Views: A activities user interface is inherited from the Android.view.View. The layout of views is managed by android.view.ViewGroups.
    • Services: Background tasks that do not require UI presentation. Users can be prompted via the Android alert framework.
    • content Provider: Provide data for your program, and content Provider your program to share data with other programs. The Android SQLite database can be viewed as a content Provider.
    • Intents: is an asynchronous messaging system that can fetch data from other systems or services. Programs can call a service or activity directly, or request an Android system.
    • broadcast receiver: accepts system messages or implicit intent that can react to changes in the system. A program can register as broadcast Receiver for certain events, and the program executes when an event occurs.
Security and Licensing

Android has a special license for some tasks. For example, if a program needs to use the Internet, then it needs to obtain the appropriate license in his configuration file. During the installation process, the user can confirm that the program has been licensed accordingly.

Androidmanifest.xml

Each Android program is described by Androidmainfest.xml. All activity, services, broadcast receiver, and content provider must be declared in this file. You also need to include the license required by the program. For example, if a program needs to access the network, it must be declared. "Andrmanifest.xml" can be considered a deployment statement for Android programs.

<?xml version="1.0"encoding="Utf-8"? ><manifest xmlns:android="http://schemas.android.com/apk/res/android" Package="Com.rockux"Android:versioncode="1"Android:versionname="1.0"> <application android:icon="@drawable/icon"Android:label="@string/app_name"> <activity android:name=". Convert"Android:label="@string/app_name"> <intent-filter> <action android:name="Android.intent.action.MAIN"/> <category android:name="Android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> <uses-sdk android:minsdkve rsion="9"/></manifest>

The package property defines the underlying library. He must be the only one. So the better way is to use the reverse of your own domain name, to prevent conflicts.

"Android:versionname" and "Android:versioncode" are used to indicate the version of your program. Versionname can be any string to the user to see, versioncode must be an integer, this is the market used to determine whether your program is updated by a flag. Usually starting from 1, and then releasing a new version on + 1.

"Activity" defines the actions under this class.

The "Uses-sdk" property is used to determine the minimum version of the SDK your program needs, preventing your program from being installed on an unsupported SDK.

R.java Resources and assets

The Gen directory in your Android project contains some of the generated files. The generated "R.java" contains the resource files in the Res file in the project. The resources deployed in the Res folder can be menus, layout icons, pictures, animations, and so on. For example, a resource file can be a picture or some XML file that contains some strings.

If you create a new resource, he is automatically created in R.java. His reference is an integer value, and the Android system has some ways to access this resource. For example, you can use GetString (r.string.yourstring) to access your character resource references, but it is best not to change the R.java.

Assets can hold any type of data, and in Java you can access it through the Assetsmanager and Getassets () methods.

actions (activities) and layouts (layout)

The user interface of the action is determined by the layout. Layout is an example of android.view.ViewGroups. Layout defines the UI elements, their properties, and their placement. UI elements are based on Android.view.View.

Layouts can be defined by Java code or XML files. You can use the Java code layout when you do not know the content, such as your content is the data obtained from the Internet.

The XML-based layout is defined in/res/layout. These files describe the view groups, views, and their relationships and specific properties. If a UI element needs to be accessed through Java code, then you need to give the element a unique ID by android.id.

Defining layouts through XML is a more recommended way of separating the logic of views and programs and managing them better.

action (activities) and life cycle (lifecycle)

The operating system controls the life cycle of the program. The operating system can interrupt the program at any time, such as having a call. Android has some pre-defined life-cycle methods for actions, and more importantly:

    • Onsaveinstancestate (): Called If the action is stopped. Used to store data so that it can be restored to its original state when it is restarted.
    • OnPause (): Triggered at the end of the action to release resources and store data.
    • Onresume (): triggered when an action is restarted, used to initialize the program
Context

The Android.context.Context class provides methods for communicating with the system. He is an interface to the program's global information. Contexts provides a message that the Getsystemservice method can use to receive different hardware. As an action and service, you can access it directly through this.

Reprint Please specify:
Rockux–web Front End
From: "Android development Tutorial" First, the basic concept

Introduction to Android System development

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.