Some ways to optimize "Android" performance

Source: Internet
Author: User

--This article is reproduced from the network, the specific source is unknown--

1. With hardware acceleration, application Add android:hardwareaccelerated= "true" in Androidmanifest.xml. But this needs to be used on Android 3.0.

2. Set cache properties in View. Setdrawingcache is true.

3. Optimize your layout. Use the layoutopt command in the Tools directory in the Android SDK to see if your layout needs to be optimized.

4. Load view dynamically. Use Viewstub to avoid some infrequently held views for long-term hold of references.

5. Set the background image of window in acitivity to empty. GetWindow (). setbackgrounddrawable (NULL); The default background for Android is not empty.

6. Use <merge> to optimize the layout layer number. Use <include > to share layouts.

7. View the size of the heap

8. Use TraceView to view trace function calls. Targeted optimization.

9. Use of the cursor. However, be careful to manage the cursor, do not open the cursor every time. It is very time-consuming to turn the cursor on. The cursor.require is used to refresh the cursor.

10. Use ring buffer (can be implemented using linked list data structure). You can set an upper limit on the length of a list, and constantly update the contents of the ring buffer according to the gesture changes.

11. Use Surfaceview to refresh the UI in a child thread, avoiding gesture processing and drawing on the same UI thread (normal view does).

12. Use JNI to place time-consuming processing on a C/C + + layer.

13. Some can use file operations, as far as possible to use file operations, file operations faster than the database operation is about 10 times times faster.

14. Lazy Loading and caching mechanisms. The time-consuming operation to access the network starts a new thread to do instead of the UI thread.

Some ways to optimize "Android" performance

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.