Analysis on the development of Android power saving

Source: Internet
Author: User
Tags notification center

  I believe that for Android app Power saving development, all performance optimization can achieve the app's power-saving development, so a power-saving Android application, performance optimization occupies a very important position. In addition to finishing a few about the Android application of power-saving development skills. A. Performance optimization of Android power saving development

Reference, just a little,http://blog.csdn.net/wtyvhreal/article/details/44172125

two. Android power-saving development CPU frequency reduction

As we all know, in the power consumption of Android system, CPU consumes a relatively large proportion, that is, CPU usage and frequency will directly or indirectly affect the distribution and use of electricity, but unfortunately, there is no android-sdk Android developers provide CPU-like management, but now many power-saving applications or professional CPU management software provide CPU frequency reduction or even overclocking capabilities.

http://blog.csdn.net/matrix_xu/article/details/8509319 (here is a blog post written in very detailed, for reference)

three. The service of Android power saving development

In Android application development, it is inevitable to encounter service development. The Android service is something that runs in the background, with the same level of activity. Since the service is running in the background services, then it is not visible, there is no interface of things. The service, like all other components, runs in the main thread, so it cannot be used to make time-consuming requests or actions. You can open one by one threads in a service and take time-consuming actions in the thread.

We analyze the power-saving development of service from three aspects.

1. See if the service is alive and decreasing priority:

If a service work is completed, but too late to switch off or kill, the user can not see, so this service will always run in the background, is bound to power consumption. So we can lower the priority of some infrequently used service processes, and in the case of tight system memory, the service with low process priority is prone to be killed by the system. In addition, you can use the monitoring system broadcast to determine whether the service status is alive, death can be manually killed.

2. Use Intentservice instead of service development:

Once the normal service is started, it is running and must call the StopService () or Stopself () method to stop the service. In order to simply create an asynchronous, will automatically be worth the service, Android specifically provides a Intentservice class. The intentservice automatically stops after running, reducing power consumption.

3. Background execution of timed tasks alarm mechanism:

Service does not have to be running in the background all the time, the timing task is very important. Android's timed tasks are implemented in two ways, the timer class and the alarm mechanism. The timer has an obvious short board that is not suitable for long-term background running tasks. In order to make the battery more durable, each cell phone will have its own hibernation strategy, the Android phone will be in a long time without the operation of the CPU automatically put into sleep, which may cause the timer task will not run correctly. This is not the case with the alarm mechanism, which has the ability to wake up the CPU, which guarantees that the CPU will function every time a scheduled task needs to be performed. The point is: after Android 4.4, the trigger time of the alarm task will become inaccurate, and it may be delayed for a period of time before the task can be executed. This is not a bug, but an optimization of the power consumption of the system. The system automatically detects how many alarm tasks are currently present, and then executes a few tasks that trigger time, which can significantly reduce the number of times the CPU wakes up, effectively prolonging battery life.

Four. Android's network of power-saving development

In addition to the regular asynchronous network, multithreading technology, local cache, and so on, an important aspect of Android power development is: WiFi than cellular data, including 2G (GPRS), 3G more power: a) Try to transfer data under Wi-Fi, of course, this is nonsense, However, you can consider pre-loading when Wi-Fi is available, such as the ZIP package for the Application Center, offline resources for the hand Q Web application, and B) non-wi-Fi, minimizing network access, and every background interaction must be considered. Although WiFi access has accounted for 50% of mobile internet users, but some phones are set to standby off the WiFi connection, even if there is Wi-Fi signal can only switch to cellular data;

Read a blog post, the above data test, do not know whether it is correct, but can explain certain problems. Anti-screen situation: off-screen transmission, high-load download when WiFi is the most power-saving (70mA), 3G (270mA) and 2G (280mA) equivalent, is about 4 times times the WiFi, light screen situation: Bright screen transmission, high load download when WiFi most power saving (280mA), 3G (360mA) and 2G (370mA) equivalent, is about 1.3 times times the WiFi, so in the Android application of power-saving development, we can take into account the way to access the network.

Five. Android L5.0 (ART), a power developer

1. The default art run mode

New Art mode has been introduced in the latest Android 4.4 system, which has changed significantly compared to the previously popular Dalvik model. So LZ for everyone to make the following this art mode and Dalvik model difference chart, by contrast, you can see the difference between art mode and Dalvik mode.

This blog is very well written http://www.cnblogs.com/shaweng/p/3811461.html

In Dalvik, when the application runs every time, the bytecode needs to be converted to machine code via an instant compiler, which slows down the operational efficiency of the application, while in the art environment, when the application is first installed, bytecode is pre-compiled into machine code, making it a true native application. This process is known as precompilation. In this case, the startup and execution of the application will become faster. But the disadvantage of art is that pre-compiled robots take up more storage space, and the installation of the application takes a long time. But sacrificing space time for power-saving speeds is acceptable in Android applications, after all, performance improvements, faster speeds, smoother experiences, and longer battery life are more important.

After testing, Google's latest Android L system has a 36% increase in endurance compared to the previous version.

The highlights of Android 5.0 http://lib.91.com/comments/141029/21755059.html

2. Using the Jobscheduler API

In the past, if the developer wanted to get the server data back in the background, or to do some processing, the application had to listen to whether an event was occurring and set a wake-up time for itself, and once the application started running, he would need to check various environmental conditions to determine if conditions were in place to complete the work. Still need to try again later, this method is not only complex, and error-prone, it will continue to waste resources, such as when an application is awakened, found that the condition is not met can only go to sleep and set the time for the next wake again, this is a repeated process.

This problem, will refer to Jobscheduler to fix, it as a dispatch application, is responsible for when the application is awakened, to provide the appropriate operating environment, so developers do not have to let the program detect whether the environment meets the requirements, developers only need to follow the standard process, the scheduler will automatically wake up the program, Get ready to run the environment. Applications can use this scheduler to wake them up, such as when a device is connected to a charger, the scheduler wakes up programs that require processor work, lets them work, or uploads photos, updates, etc. when the device is connected to a WiFi network. The scheduler also supports a time window so that it can wake up a set of applications that will not require an exact wakeup time, but a program that needs to run once every one or two hours can run at the same point in time, allowing the processor to stay dormant for a longer period of time.

The advantages of Jobscheduler are huge, not only to help save battery power, but also to help developers reduce the amount of code written by not having to listen, change, and set alarms. Currently the Jobscheduler class has been added to the Android L Developer Preview.

3. New modes and technologies of power saving

(1) new material design-style user interface;

The new user interface is more concise and richer in color. Animation effect more reasonable and vivid, while adding real-time shadow 3D view, more use of card-style display effect. The full platform style is also becoming more unified.

(2) A new notification message system;

Allows the user to manage notification messages in the Notification center. The original Android notification bar is almost out of control, all app notifications pop up, and you want to turn it off into each app individually, or use third-party software for unified management. But for now, Android 5.0 has its own notification management interface.

(3) The multi-tasking interface has a brand new Google Now card style;

The notification center incorporates more card style, which can be operated in a variety of functions even in the lock screen state. At the same time, users can customize the priority level of notifications, so that users do not miss any important notifications. You can also set specific notification permissions, and only the allowed notification messages will be pushed. At the same time also has the operability, for example the user in the game has the telephone to enter, does not appear in the full screen, but pops up the operational notification card, the user may choose to answer or reject the connection, does not affect the game to continue.

(4) Project Volta Power saving mode, Batterysaver power saving mode;

The power-down mode of Android 5.0 is powered by JOBSCHEDULERAPI and automatically adjusts screen brightness, refresh rate, and uses Project Volta to quantify the power consumption of each application. In the case of a mobile phone without power, actively reduce the CPU frequency or shut down the communication module, in order to obtain a longer standby time. Also comes with a battery bistorian battery history feature that lets you display the power consumption of the device in detail.

Six. Reference Reference

http://blog.csdn.net/dyllove98/article/details/43407093

http://blog.csdn.net/matrix_xu/article/details/8509319

Http://lib.91.com/comments/141029/21755059.html

Http://tech.qq.com/a/20140702/026949.htm

Http://news.mydrivers.com/1/310/310617.htm

Http://mobile.51cto.com/abased-419415.htm

Http://www.pc841.com/shoujizhishi/28594.html

Http://mobile.51cto.com/news-417703.htm

Analysis on the development of Android power saving

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.