Android program running performance optimization

Source: Internet
Author: User
Android ProgramPerformance Optimization

Original article address

For Android phones, Google is fully open to multi-tasking while running Java-based explanatory languages, causing a great deal of Ram overhead. With the development of Android platforms, many novice programmers have experience and other issues, your application execution efficiency is low. Pay attention to the following points for published applications:

I. Use logcat output with caution

If your application always outputs logs in the background. I or log. d content, in addition to increasing system overhead, affects the overall efficiency of your application, especially the continuous output of a lot of content. Because logs require underlying JNI calls, the overhead of Java virtual machines is not small.

Ii. proguard disturbance

For Android app encryption, the disturbing rule may not only modify the name of classes and variables, but also addAlgorithmThe complexity may change from 1 + 1 = 2 to 2*10-10-8. Of course, android123 is an example to illustrate the working principle of disturbance, this may change the running efficiency of the program and some logic. Therefore, we need to weigh whether to modify only the variable name for the configuration disturbance.

3. Basic Knowledge

1. Access variables are faster than accessing fields of A Class/

2. When determining whether the array is null, The getcount () = 0 method is generally not used. It can be processed directly using the isempty () method.

3. Use global static classes with caution in many cases.

4. Many of the CPU usage of the Android Application is put on the JVM resources. Therefore, it is helpful to reduce the memory release or increase the mobile phone Ram to execute the program as much as possible.

5. Register as few System broadcast notifications as possible. At the same time, you can rewrite onpause or onresume to control the display of activity to obtain some system broadcasts.

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.