Android Quick Start Summary

Source: Internet
Author: User

The launch of the Android mobile phone operating system has brought a lot of vitality to the smartphone field, and its open source nature has helped many businesses gain great development opportunities. The Android system framework and upper-layer applications are developed in a way similar to java, not the Orthodox sun java) and implement their own java Virtual Machine dalvik. Since java Virtual Machine and java are used for development, efficiency is generally considered low. In fact, Android is the fastest running speed on basically mainstream smartphone software platforms.

  • Concepts related to Android screen elements
  • Android Virtual Devices apply to your deployment goals
  • Run commands in Android adb
  • Android menu construction skills
  • Android Image Browsing source code

Why is Android efficiency so high? In particular, the startup time of an application is very short. This article mainly analyzes the following aspects of Android Quick Start:

1. Optimized reading of resource files.

We know that Android has a major advantage in UI development: the xml file is used to describe the UI, in this way, you can modify the layout, display style, and font size of the UI without modifying the code. The interface definition becomes flexible and convenient. The xml configuration UI is also used in qtopia, but it is so powerful and not widely used, because the xml file is inefficient in parsing xml.

How does Android do it?

Android optimizes the xml file during compilation, and the Android application becomes very efficient in parsing, so as to enable quick Android startup. We can see that there will be an optimized resource file after the apk file is decompressed.

2. Optimize the dex file during installation

Android applications are packaged into an apk file, which is actually a zip file. When the system is started for the first time or the application is installed for the first time, the system decompress the apk file, optimize the executable file dex to the odex file, and put it in the/data/dalvik-cache directory. The optimized dex file starts faster. This explains why the first startup of the Android system is slow and will soon become faster.

Some may ask: why is it not directly optimized during compilation? The 5th item will answer this question.

3. Create a database

Android graphics applications load all the images in the entire SD card, but why is it so fast? In fact, Android has made the data into a database in advance, so it does not need to scan the entire SD card every time, which greatly speeds up startup.

4. Efficient Virtual Machine for Android Quick Start

Android is based on Java-like virtual machine dalvik. Generally, Java virtual machines are stack-based, while dalvik is based on registers. In fact, I do not know much about the differences between the two, but I have a special online analysis of relevant literature. My simple understanding is that the stack implementation method is relatively easy. The relevant data is in the memory stack, and the data speed in the Operation register is significantly faster than the data processing in the memory.

5. Fully explore CPU Performance

Although Android supports arm cpu when it first came out, it actually only supports armv5te instruction sets. Because the Android system is specially optimized for armv5te, it makes full use of the execution pipeline of armv5te to improve the execution efficiency, this is also the reason why 2440 M Samsung does not work well, and m omap cpu runs smoothly, therefore, the latest Code provides Optimization for x86 and armv4.

6. Optimized and cropped libc library

The Libc library is almost the basis of the library and program, but Android did not directly use the libc library, but developed a library: bionic, it implements the vast majority of libc library functions and optimizes them based on the platform. However, a few functions that are rarely used in the system and consume resources are not supported. It only has several hundred kb, saving space and improving execution efficiency. In fact, the 20-80 principle is embodied, and it is necessary to discard unnecessary ones by grasping a few important ones.

7. Make full use of linux system features

Friends who have analyzed the linux kernel know that a new process of linux fork is very efficient and uses the COW mechanism. Android is an independent Virtual Machine for every process. It is said that this design is for security considerations. A process crash at some time will not affect the system and other processes .) Every process in Android is based on virtual machines, and basic libraries must be loaded. In fact, these are shared. Therefore, starting a new program in Android does not actually consume a lot of memory and cpu resources.

At the same time, Android has an empty process running in the background, which is actually running a virtual machine. When an application is to be started, it runs directly on it. qtopia also has this mechanism.

In the boot process of the Android system, choose start virtual machine> Start system server> Start launcher. Why not start system server directly when I analyzed the code? Qtopia directly starts the server). In fact, this feature of linux is also used.

This feature is simple, but it may take a lot of time to explain it clearly.

8. Efficient paint Mechanism

This feature may have little to do with Quick Start of Android, but it is also one of the most efficient features of Android. Most of the page changes are not actually full-screen content changes, but partial changes. Android only follows the new partial content based on the changed content, which also improves the efficiency. This also reminds us to try not to paint full screen content when reloading the paint method during application development.

Related Article

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.