Mount Basic specification for Android high performance programming

Source: Internet
Author: User

Recently summed up some of the things that need attention in Android app development, share   1 with everyone. DECLARE global variable  2 as few as possible. Declare a global static variable, and be sure to add the final declaration  3. Declares a non-static global variable, It is best not to initialize any values, where they are used, to initialize the  4. The global variable is used several times in the function, the global variable should be assigned to the local variable, and then the local variable  5 is used directly. can use int, do not use floating-point number   6. can use multiplication without division  7. Try to avoid using the Geter and setter methods  8. In the activity's OnCreate function, do as little as possible.  9. Static arrays or static blocks of code declared in the activity are refactored into a single class.  10. layout files should be optimized as much as possible, reducing the parsing time of layouts. Minimize the nesting level of the layout  11.activity start the asynchronous thread loading after startup, preferably delay. Then turn on thread  12. For bean objects that exist in the collection, declare as few variables as possible. You can use int instead of a long. A complex variable such as a string that is declared, preferably not initialized.  13. Use a thread, be sure to give it a name, and then you need to define the thread's priority  14. When using a collection, select Sparsearray first.  15. Avoid using enumeration  16 as much as possible. The tool method is written as a static method  17. Synchronization between threads is used as much as possible with a small overhead synchronization lock  18. When using the collection class, if the size of the data is known, the default size is set when initialized.  19. Private inner class accesses the private variable of the external class and modifies the variable to the package inheritance permission  20. For expensive algorithms, and more than once, use the cache policy  21. Avoid assigning objects when plotting or parsing layouts. For example, the OnDraw method  22. Do not write useless parameters to the layout, such as Relativelayout, write Layout_weight property  23. Minimize the number of nesting layers for the layout. For example, a linear layout with a ImageView and TextView can be used instead of  24 using Compounddrawable's textview. Try to replace Sparsearray with Android-provided hashmap  25. If LinearLayout is used for nested layouThe T-space calculation, with its android:baselinealigned set to false, can speed up the layout calculation  26. Use Floatmath instead of math 27. Avoid nesting using layout_weight as much as possible. That will affect the execution efficiency  28. If the background is set for Rootview, it is drawn with the background of the theme specified before drawing with the specified background, which is called "overdraw" and can be avoided by theme background as null.  29. Don't have any useless resources or files   excerpt from: http://blog.csdn.net/litton_van/article/details/21956859

(installed) Android high-performance programming basic specification

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.