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.