I. Android Application Architecture
After installing Android to IDE, we can see the following program architecture:
L src
Directory for storing original java code
L gen
The gen directory stores all files automatically generated by Android development tools. The most important part in the directory is the R. java file. This file is automatically generated by the Android development tool. The Android development tool automatically updates and modifies the R. java File Based on the xml interface files, icons, and constants in the res directory. Because the R. java file is automatically generated by the development tool, we should avoid manual modification to R. java. R. java plays a dictionary role in the application. It contains the IDs of various resources such as interfaces, icons, and constants. Through R. java, the application can easily find the corresponding resources. In addition, the compiler checks the R. whether the resources in the java list are used, and those that are not used are not compiled into the software. This can reduce the space occupied by applications on mobile phones.
L Res
In this directory, we can store various resources used by applications, such as xml interface files, images, and data. For details, see the remarks column below the ppt.
L AndroidManifest. xml
Function list file, which lists the functions provided by the application. In this file, you can specify services used by applications (such as telephone services, Internet services, SMS services, and GPS services ). In addition, when you add an Activity, you also need to configure it in the file. Only after the Activity is configured can you call the Activity.
L default. properties
Project Environment Information, which generally does not need to be modified
2. Compiling Application Ideas
Before creating an application, we must configure the AndroidManifest. specify the basic information, sample tag, title, and application name of the application in xml. (You can configure string in values to set related values. xml), and then we need to register an activity (generally an application corresponds to an activity). Then we can register the intent. Details are as follows:
<Intent-filter>
<Action android: name = "android. intent. action. MAIN"/>
<Category android: name = "android. intent. category. LAUNCHER"/>
</Intent-filter>
The above indicates that the intent filter matches the intent, so there is activity to handle this matter. For example, when we click the icon, It is encapsulated into an intent (the action and category parameters ), then android. intent. action. MAIN is encapsulated into an action, android. intent. category. LAUNCHER is encapsulated into a category, and then the intent filter that matches the two parameters finds the corresponding activity
Next, we need to modify the drawable icon information in res, layout (modify layout information main. xml) and values (modify string information ). After the configuration, write the corresponding business logic code and publish it to your mobile phone.
Iii. Operating Principle
When you click an application, the system automatically creates an activity-class instance, runs the Oncreate method, and then runs the following two lines of code:
Super. onCreate (savedInstanceState); Be sure to execute. Complete drawing
SetContentView (R. layout. main); specifies the file to which the layout (main. xml), this interface can be displayed, and then we perform relevant operations, our operations will be encapsulated into an intent, and then this intent will process relevant activities.
Author: jpr1990