Android self-study Note 4-application Structure Analysis

Source: Internet
Author: User

An analysis method I saw in my post yesterday is very simple. I 'd like to share it with you!
 
Haha, since I was just learning Android and haven't learned the following knowledge, I will go straight here.
 
After reading his analysis, I have a simple understanding of the Android program. If I want to have a deep understanding, I think I will spend a lot of time here .... You have to work hard ....
 
Now, let's introduce his analysis method:
 
He uses "Hello" and "World" as an example. By analyzing the directory structure of "Hello" and "World", we have a comprehensive and comprehensive understanding of the Android program.
 
Let's take a look at the display result of Lesson2_Helloword:
 
 
 
Then let's take a look at the Helloword program directory:
 
 
We can see that:
 
1. MainHelloWorld. java File
 
2. R. java File
 
3. android. jar File
 
4. RES, Layout, and main. xml files
 
5. androidmainfest. xml file
 

Next we will explain one by one:
 
1. Analysis of Activity and MainHelloWorld files
 
 
 
Activity is the view part in Android and is responsible for display on the interface.
 
 
 
Package android. basic. lesson2.helloworld; import android. app. Activity;
 
Import android. OS. Bundle; public class MainHelloWorld extends Activity {
 
/** Called when the activity is first created .*/
 
@ Override
 
Public void onCreate (Bundle savedInstanceState ){
 
Super. onCreate (savedInstanceState );
 
SetContentView (R. layout. main );
 
}
 
}
As you can see, MainHelloWorld is a subclass of Activity, and the onCreate method must be rewritten for the subclass.
 
The setContentView (R. layout. main) method sets a View that can be displayed for the Activity. The View is searched by the R class.
 
2. Analysis of R files
 
We can see that there is an R. Java file under the Gen directory. The R file is automatically generated by the ADT, and programmers do not need to modify it. The R file is responsible for calling non-code Resources in the application.
 
 
 
From the R file, we can see that each resource has an integer corresponding to it.
 
3. Analysis of res/layout/main. xml file-layout
 
We can see that there is a res directory, that is, the resource Directory, which stores resource files and manages resource files in a unified manner, which is also a major feature of the Android system. Note that the main. xml in the layout directory is used. The content of this file is related to the layout and design of the user interface. XML may be novel in desktop programming, but it is common in web design.
 
 
 
 
 
 
The code above shows that the entire program interface consists of a linear layout control (LinearLayout) and two textviews. Other files in other directories of res are also related resource descriptions.
 
4. AndroidManifest. xml file Analysis
 
There is an AndroidManifest in the root directory of each application. xml file, which describes the components, functions, processed data, and requested resources of the program to the Android operating system.

.
 
We can see that Manifest is the root node. versionCode and versionName are contained in the node attribute to indicate the application version. It can contain 0 or 1 application element, the application can contain multiple activity components. The specific content is described in detail in the next course.
 
5. Analysis of Android. jar files
 
As a Java project, the tool class to be used, that is, the Jar package, is usually introduced. In Android development, most development kits are encapsulated into a tool named Android. jar file.
 
If we show it in Eclipse, we can see the packages in j2se, apache project, and Android package files. Here we will briefly look at the Android package file:
 
Android. app: provides high-level program models and basic runtime Environments
Android. content: contains various classes for accessing and publishing device data.
Android. database: browses and operates databases through content providers
Android. graphics: The underlying graphics library, including canvas, Color Filtering, vertices, and rectangles, which can be directly drawn to the screen.
Android. location: class for locating and Related Services
Android. media: Provides media interfaces for managing multiple types of audio and video.
Android.net: class that provides network access assistance, exceeding the normal java.net. * interface
Android. OS: Provides system services, message transmission, and IPC Mechanisms.
Android. opengl: Provides OpenGL tools.
Android. provider: provides a class to access Android content providers.
Android. telephony: provides API Interaction Related to dialing.
Android. view: provides a basic user interface framework.
Android. util: a tool-based method, such as time and date operations.
Android. webkit: default browser operation interface
Android. widget: contains various UI elements (mostly visible) used on the application Screen


From Guo Zi's blog
 

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.