Excellent experience comes from excellent performance

Source: Internet
Author: User

Excellent experience comes from excellent performance, and excellent performance is nothing more than starting from the following aspects: reduce power consumption, reduce CPU usage, balance CPU usage, recycle memory in time, avoid frequent GC, and sleep the device in time.

Here are some specific implementation start points.

Alarmmanager
Do not use the timer with no restrictions. register the timer selectively based on the scenario and log off the timer in time. For example, syncadapter should be used to depend on network conditions. After you log out, remember to log out the timer.
In addition, it is recommended that the timer cycle be controlled for more than 15 minutes. This is an experience value officially provided by Android. If it is more frequent, the impact on the consumption of electromechanical resources will become larger.
About the timer mode. The advantage of wakeup is that it can update the user's concerned status in a timely manner, but will interrupt the machine sleep. If it is frequent, the machine will not be able to sleep, and the power consumption will increase significantly. The advantage of non-wakeup is that it saves power, but all the tasks will be executed at the moment when the user wakes up the machine, resulting in a choppy pause when the user wakes up the machine.

Wake lock
In addition to video playback, even if the user does not perform operations for a long time, it must be maintained at the front-end.ProgramIn essence, there is little need to apply for a wake lock. In addition, once the program exits, remember to release it.

Broadcast
The global broadcast receiver declared through androidmanifest. XML is a large power-consuming device. There may be many common events such as "network status change", "phone status", and "unlock. When these events occur, multiple processes are triggered, and frequent GC occurs. Therefore, use dynamic registration whenever possible.
In addition, the syncadapter provided by android can be used for low-cost listening for "network status change.
Worker er's Process configuration also has some tips. If the worker ER needs to wake up the UI process, configure it and the UI to a process. If you need to wake up the background service, configure it and the background service to a process. This reduces the overhead of system creation processes.

Background Service
Using the background service as a single process can greatly reduce the memory pressure of the UI process. If you put them in a process, they will remain in the memory as long as any of them has not completed the task.

Persistent connection
Persistent connection means that you need to maintain network connections, periodically transmit heartbeat data, and the device cannot sleep. Therefore, be cautious when using this function.

Bitmap
The concept of memory release is not in Java design, except for large objects in actual use. Bitmap in Android is such an exception. If bitmap is not recycled in time, the memory usage will soar. For detailed analysis, refer to this article.Article.
Bitmap recycle method and memory cache for making bitmap:

Http://blog.csdn.net/a345017062/article/details/7963081

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.