1, Android Introduction 1.1 Android System architecture
The following diagram shows the system architecture of Android:
The figure shows that Android can be roughly divided into four-tier architectures and five areas:
- Linux kernel layer (Linux Kernel)
- The Android system is based on the Linux2.6 kernel, which provides the underlying drivers for various hardware on Android devices, such as display drivers, audio drivers, camera drivers, bluetooth drivers, WiFi drives, power management, and more.
- System operating Layer
- This layer provides major thermal support for Android systems through a number of C + + libraries, such as the SQLite library, which provides database support, opengl| The ES Library provides support for 3D drawings, and the WebKit Library provides support for the browser kernel. At the same time, there is the Android Runtime Library, which provides core libraries that allow developers to write Android apps using java. The key is the Dalvik virtual machine, which allows each of our Android applications to run in a separate process, and has a own Dalvik virtual machine instance, compared to the Java Virtual Machine (JVM), Dalvik is specifically for mobile devices, it on the phone memory, CPU performance is limited and so on the situation has been optimized processing.
- Application Framework layer (application framework)
- This layer primarily provides some of the core applications that may be used to build applications using these APIs, and developers can build their own applications by using these APIs. api,android For example, there is an Activity manager, view system. Content providers, notification managers, and so on.
- Application Layer (applications)
- All applications installed on the phone are on this level, such as the system's own contacts, SMS programs, or the programs we download from Google Play, including our own apps.
1.2Android Application Features
Currently the latest version of Android is 5.0 version, the main features of Android, the following we will introduce:
- Four components
- Rich system controls
- Persistent technologies such as SQLite database
- Location targeting
- Powerful multimedia
- Sensor
1.2.1, four components What are the four components? Activities, services, broadcast receivers (broadcast receiver), and content Provider are respectively included. The activity is what the Android app looks like, and the user opens the façade of an application and interacts with the user's interface, which is more high-profile. Service, it is relatively low-key, has been in the background silently pay, even if the user quit, the service is still able to continue to run. The broadcast receiver (broadcast receiver) allows your app to receive broadcast messages from everywhere, such as phone calls, text messages, and so on, depending on the broadcast name, to do the corresponding operation, of course, in addition to accept other people sent broadcast messages, they can also send out broadcast messages, Homegrown Content Provider, it is possible to share data between applications, for example, if you want to read the contacts in the system phone book, you need to do so through a content provider. 1.2.2, Rich system controls Android provides a rich system control for developers, we can write beautiful interfaces, or you can extend system controls, customize controls to meet the needs of the self, Common controls are: TextView, buttion, EditText, some layout controls, and so on. 1.2.3, persistence technology The Android system also has its own SQLite database, SQLite database is a lightweight, computationally fast embedded relational database. Not only does IT support standard SQL syntax, it can also be manipulated through the Android encapsulated API, making it easy to store and read data. 1.2.4, geolocation mobile devices and PCs compared to geolocation is a big highlight, now basic Android phones are built with GPS, we can use GPS, combined with our ideas, To build a product based on lbs, is not a cool thing ah, besides, the current hot lbs application is not unfounded, but in the celestial, because the GFW, can only use some localized map API, such as Baidu Map, high-gold map. If one day can use big Google's map, that is tall on AH. 1.2.5, the powerful multimedia Android system offers a rich multi-Media services such as music, video, audio recording, photo shooting, alarm, etc. can all be controlled by code in the program to make your application more colorful. 1.2.6, sensors There are a number of sensors built into the Android phone, such as acceleration sensors, directional sensors, which are a major feature of mobile devices, and we have the flexibility to use these sensors You can make a lot of apps that can't be implemented on your PC. For example, "Shake a Shake" _ You know, "Search songs Shake" and other functions.
1.3Android Development environment
Development environment to build the necessary software, configuration, etc., I believe we search online search, this kind of article too much. Only a few important tools are highlighted here: Android SDK, Eclipse, ADT.
1.3.1,android SDK Android SDK Google offers Android Development Kit, when developing Android programs, we need to reference the toolkit, which contains the development of Android app API. 1.3.2,eclipse development of Java application artifacts, preferably with one of the IDE tools, characterized by open source, super plug-in features, can support multiple language development. Of course, Google also launched Android Studio, specifically for Android programs, but because Android studio was just introduced soon, not too stable, after all, the new tool problem is still more, eclipse is applied is very mature, There are a lot of solutions to eclipse's problems on the web, compared to Android studio. 1.3.3,adt ADT, called "Android development Tools", is an Eclipse plugin provided by Google to provide a powerful, integrated Android development environment in eclipse. 1.4ANDROID Program Structure
is an example diagram of the Android program structure:
With this picture we can have a clear understanding of the structure of the Android program:
1.4.1,src There is no doubt that the SRC directory is where all of our Java code is placed, and its meaning here is exactly the same as the SRC directory under ordinary Java projects. 1.4.2,gen Content in this directory is automatically generated, There is a R.java file that you can add any resource to the project to generate a corresponding resource ID, which is never manually modified. 1.4.3,assets This directory can be used to store a number of files packaged with the program, you can dynamically read the contents of these files while your program is running. In addition, if you use the WebView to load the local Web page, all the pages related files are also stored in this directory. 1.4.4,bin This directory page does not require much attention, it mainly contains some files that are generated automatically at compile time. Of course, it will include a compiled installation package with the suffix. apk file. 1.4.5,libs If you use a third-party jar package in your project, you will need to place the jar packages in the Libs directory, and the jar packages placed in this directory will be automatically added to the build path. 1.4.6,res The contents of this directory is a bit more, simply put, you use in the project all the pictures, layouts, strings and other resources to be stored in this directory, The contents of the R.java mentioned above are also automatically generated according to the files in this directory. Of course, there are many subdirectories under this directory, the images are placed in the drawable directory, the layouts are placed in the layout directory, and the strings are placed in the values directory. 1.4.7,AndroidManifest.xml This is the configuration file for your entire Android project, and all four components you define in the program need to be registered in this file. You can also add permission declarations to your application in this file, or you can reassign the minimum and target versions of the program that you specified when you created the project. 1.4.8,proguard-project.txt When you publish your program, some APK files are easy to decompile, so this file works at this point, withTo confuse your program code, making it less easy for others to see the source code. 1.4.9,project.properties The SDK version 1.5Logcat tool log, which is used to compile the program, plays a very important role in the development of any project, and you must use the Logcat tool if you want to view the log in the Android project. Android provides a log tool class is log, with a total of one rank, and a level increment.  1.5.1,LOG.V ()
This method is used to print the most trivial, least meaningful log information. The corresponding level verbose is the lowest level in the Android log.
1.5.2,LOG.D () This method is used to print debugging information that is useful for debugging programs and analyzing problems. The corresponding level of debug, higher than the verbose level.
1.5.3,LOG.I () This method is used to print some of the more important data that you would like to see that can help you analyze user behavior. corresponding level info, higher than Debug. 1.5.4,LOG.W () This method is used to print some warning messages, suggesting that the program may have potential risks in this place, and it is best to fix the warnings where they appear. Corresponds to level warn, one level higher than info.
1.5.5,LOG.E () This method is used to print error messages in a program, such as a program entering a catch statement. When the error message is printed, it usually means that your program has a serious problem and must be repaired as soon as possible. The corresponding level of error, higher than the warn level. Small reminder: Customize your own Log tool
For example, you are writing a large project, during which a large number of logs are printed in many parts of the code for ease of debugging. Recently the project has been basically completed, but there is a very troublesome problem, the previous debugging of those logs, the project will continue to print after the official launch, which will not only reduce the efficiency of the program, but also the possibility of some confidential data disclosure.
What do you do, do you want to delete all the print log code in one line? Obviously it's not a good idea, it's not just a time-consuming effort, but it may also be needed in the future when you continue to maintain the project. Therefore, the ideal situation is to be able to freely control the printing of the log, when the program is in the development stage let the log print, when the program is online after the log screen off. [1]
References: [1]
"About Android" first: Android system introduction http://www.cnblogs.com/cr330326/p/4229026.html
"Android Learning Journey" 1, Android Introduction