User experience-oriented Android app development-Save power
A device that is plugged into a wall at any time, not called a mobile device. If your app keeps users in the corner, users will quickly throw you in the corner. You'll ask, "How did he know my application was draining?" "Sorry, at present, Android users have a large number of enthusiasts and technical experts, while the system is very rude to record the power consumption of each application, so users occasionally go to the system backstage to check the power, then will open the Uninstall tool without a courtesy.
Therefore, the following points should be noted:
1. Do not try to design complex algorithms, do not run in the background service, do not stop the network is still retrying.
Before developing a module, think about whether it will cost electricity, and if so, don't do it. The code is meant to serve the user, not toss the user.
Experts like the challenge, especially in the mobile phone to achieve a sophisticated algorithm, this can bring a stronger sense of conquest. Some people have implemented the Bron filter on the mobile phone (a large and sophisticated class hash table, used in server-side such as spam lookup), its memory consumption and computational complexity is much higher than the ordinary hashmap, and implementation is not easy. Results after the app was released, users complained of high power consumption, and often bug, and finally the HashMap replaced. The purpose of any algorithm is to serve the user, if the simple and natural way to do this better, why not? If you really can't find a simple algorithm on the client, you need to rethink-why do you need complex computing on your phone? Should these calculations be placed on the server side?
2. Do not misuse the service in the background. Android is very open, and developers can trigger any processing logic in the background, consuming CPU and memory.
In general, the service is designed to monitor changes, including system and network changes. System changes can be registered Broadcastreceiver monitoring control, such as application installation and uninstallation events, so that the power consumption is very small, completely replace the service in the carousel. Network requests cannot be monitored with broadcastreceiver, but there are two recommendations.
? Without stringent real-time requirements, you can extend the carousel interval, such as 6-hour automatic requests, while the time interval can be updated online via the server. This saves power and occasionally requires an online adjustment of the time interval when real-time push is needed.
? For real-time requirements, consider using a proven push service, such as Google's C2DM (http://code.google.com/android/c2dm/), and Amazon's AWS SDK (http://aws.amazon.com/ Sdkforandroid/).
3. Network requests are not too frequent.
The most power consumption in the system components is the screen, followed by the network. As mentioned earlier, network error re-hair can degrade the user experience and consume power. The number of network requests can be reduced by data prefetching combined with data compression algorithms.
In short, in the development of our users to think about whether the "smooth, friendly, power-saving" to ensure that the app has a good user experience.
Transferred from: http://www.ideasandroid.com/archives/380
Solutions to reduce the power consumption of Android applications