one of the most valuable resources in handheld devices, and most devices need to be recharged continuously to maintain their use. Unfortunately, for developers, power optimization is the last thing they'll think about. But you can be sure that you can't make your application a big drain on your battery.Purdue University studied the power consumption of some of the most popular applications, with an average of about 30% of the power being used by the program's core methods, such as drawing pictu
Context.power_service. The PowerManager method "WakeLock newwakelock (int flag, String tag)" Can obtain a WakeLock instance where flag can be one of the following:
Partial_wake_lock (constant value 1)
Screen_dim_wake_lock (constant value 6)
Screen_bright_wake_lock (constant value 10)
Full_wake_lock (constant value 16)
I use Screen_bright_wake_lock in the example, and the correspon
PerformancePower is actually one of the most valuable resources in handheld devices, and most devices need to be recharged continuously to maintain their use. Unfortunately, for developers, power optimization is the last thing they'll think about. But you can be sure that you can't make your application a big drain on your battery.Purdue University studied the power consumption of some of the most popular applications, with an average of about 30% of the power being used by the program's core m
UI is blocking, although our mtimecount this textview is not updated in real time, the timing function is still in progress, and when the UI thread's Thread.Sleep () ends, it is updated.Here's a look at the logic to keep the screen awake:private static Powermanager.wakelock WakeLock; public static void Keepscreenon (context context, Boolean on) { if (on) { PowerManager pm = (powermanager) Context. Getsystemservice (context.power_se
PerformancePower is actually one of the most valuable resources in handheld devices, and most devices need to be recharged continuously to maintain their use. Unfortunately, for developers, power optimization is the last thing they'll think about. But you can be sure that you can't make your application a big drain on your battery.Purdue University studied the power consumption of some of the most popular applications, with an average of about 30% of the power being used by the program's core m
screens and duration, use Wakelock to handle wake-up problems, be able to perform wake-up operations correctly, and close the operation to sleep according to the set-up time.
Some actions that do not have to be performed immediately, such as uploading songs, picture processing, etc., can wait until the device is charging or has sufficient power.
Triggering the operation of the network request, each time will keep the wireless signal for a per
the second method: PowerManager.
Android. OS. PowerManager can control whether the screen is always on. Its service name is Context. POWER_SERVICE. The PowerManager method "WakeLock newWakeLock (int flag, String tag)" can obtain a WakeLock instance. The flag can be of the following types:
PARTIAL_WAKE_LOCK (constant value 1)
SCREEN_DIM_WAKE_LOCK (Constant Value 6)
SCREEN_BRIGHT_WAKE_LOCK (constant va
:
We should minimize the number and duration of screen wakeup. We should use WakeLock to handle the wake-up problem, correctly perform the wake-up operation, and close the operation in time to enter the sleep state.
Some operations that do not have to be performed immediately, such as uploading songs and image processing, can be performed only when the device is in the charging status or when the power is sufficient.
The
, such as drawing pictures, placing layouts, and so on, and the remaining 70% or so of the charge is reported data, check location information, Time to retrieve background advertising information used. How to balance the power consumption of both is very important.There are several measures that can significantly reduce the consumption of electricity:
We should try to reduce the number of wake-up screens and duration, use Wakelock to handle w
This article mainly introduces the Android phone to keep the screen highlighting method, this article directly gives the implementation code, the need for friends can refer to the
First contact with the Android application project, in the project quickly when the planning requirements add a highlight, each time is directly from the online Baidu, now do the game, but still this demand, here to back up a convenient follow-up search, after all, is their own write and verify that there is no proble
First contact with the Android application project, in the project quickly when the planning requirements add a highlight, each time is directly from the online Baidu, now do the game, but still this demand, here to back up a convenient follow-up search, after all, is their own write and verify that there is no problem:
First, add the code to the activity:
Member Variable:
Private Powermanager.wakelock wakelock = null;
Rewrite two methods o
The example in this article describes how Android keeps the screen illuminated steady wake state. Share to everyone for your reference, specific as follows:
First step: Add Permissions First:
Copy Code code as follows:
Step Two: Code implementation is as follows:
public class Screenactivity extends activity
{
PowerManager powermanager = null;
Wakelock wakelock = null;
@Ov
First contact with the Android application project, in the project quickly on-line planning requirements to add a highlight, each time is directly from the online Baidu, now do the game, but still this demand, here to back up a convenient follow-up search, after all, it is written well and verified that no problem:) First, add the code to the activity: Member Variable:privatepowermanager.wakelockwakelock=null; Rewrite the two methods of parent activity and add logic: @Override publicvoidonresume
On Android, applying for Wakelock can keep your process going even if your phone goes into sleep mode, it's useful to have a network function in the background, which can keep the operation going.Method: Join before the operationPowerManager pm = (powermanager) mcontext.getsystemservice (Context.power_service);WakeLock = Pm.newwakelock (Powermanager.partial_wake_lock, Constants.tag);Wakelock.acquire ();Wher
video or movie, the cpu needs to decode the video and keep the screen on for the user to watch it.
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); WakeLock sCpuWakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,"okTag"); if (sCpuWakeLock!= null) { sCpuWakeLock.release(); sCpuWakeLock = null; }PARTIAL_WAKE_LOCK: to keep the C
not enough, but it is possible to call this function in the service under the framework.
Newwakelock (INT flags, string tag); // obtain the lock of the corresponding level
Flags parameter description:
PARTIAL_WAKE_LOCK:Screenoff,keyboardlightoff
SCREEN_DIM_WAKE_LOCK:screendim,keyboardlightoff
SCREEN_BRIGHT_WAKE_LOCK:screenbright,keyboardlightoff
FULL_WAKE_LOCK:screenbright,keyboardbright
Acquire_causes_wakeup: Forces screen and keyboard light to be turned on when a re
. Setbacklightbrightness () method, this method can set the brightness of the backlight, from 0-255Three. Timer off screenSo here, you can also introduce a control screen method is Powermanager.wakelockAs the name implies, Wakelock this thing is the light screen control, here said the bright screen, it defines several types of bright screen. As follows:
Type
Cpu
Screen
Keyboard
Partial_wake_lock
On
); } }
public void onCreate() { // TODO: It would be nice to have an option to hold a partial wakelock // during processing, and to have a static startService(Context, Intent) // method that would launch the service amp; hand off a wakelock. super.onCreate(); HandlerThread thread = new HandlerThread("IntentService[" + mName + "]"); threa
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.