Android Application Structure Analysis
Because I am a beginner, I understand the structure of Android applications. I must first understand the structure and functions of Android applications. A simple example is used for anatomy:
From the perspective of the program, there are several main files:
HelloActitity. java
HelloActitity inherits the Actitity base class. Its main function is equivalent to interface files, used to display data and interfaces to users. It is the first entry to user interaction. The code structure of the file is as follows:
It can be seen that there are two methods, onCreate (Bundle saveInstanceState) and onCreateOptionsenu (Menu menu ).
When the HelloActivity. java file is loaded, the onCreate (Bundle savedInstanceState) method is called first. Among them, super. onCreate (saveInstanceState) is to call the onCreate method of the parent class Activity; while setContentView (R. layout. activity_hello) is to set a visual view for the Activity, and the view is searched by the R class.
Res folder, activity_hello.xml in laout, string. xml, styles. xml, and dimens. xml in values
The res folder stores and manages the resource files of the entire application. The activity_hello.xml is the view settings of the helloati.pdf panel. The Code is as follows:
Activity_hello.xml is an xml file. It is rare to use xml to control desktop applications. From the code above, we can see that the interface of the program is linear layout (LinearLayout) and a text box (TextView. Other files in the Res folder are also resource descriptions in Hong Kong.
AndroidManifest. xml
Each application will have an AndroidManifest. xml file that describes the components, functions, processed data, and requested resources contained in this program to the Android system. The Code is as follows:
R. java file in the gen package
The R file is automatically generated by the ADT and is mainly responsible for calling non-code resources of the application.
From the R file, we can see that each resource has a corresponding integer.
Android. jar Development Kit
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