-
public class wakelockutil
public static wakelock wakelock = null;
public static void acquirewakelock(activity myactivity)
if (null == wakelock)
powermanager pm = (powermanager) ;
wakelock = | "wakelockutil");
Partial Wake Lock: Keep the CPU running, screen and keyboard lights may be off - most commonly used, keep the CPU running.
Screen Dim Wake Lock: Keeps the CPU running, allows the screen to be displayed but may be gray, and allows the keyboard light to be turned off.
Screen Bright Wake Lock: Keeps the CPU running, allows to keep the screen highlighted, and allows the keyboard light to be turned off.
Full Wake Lock: Keep your CPU running, keep your screen high, and keep your keyboard lights bright.
Acquire Causes WakeUp: Forcibly lights up the screen, a lock that focuses on actions that must notify the user.
on after release: When the lock is released, keep the screen on for a while.
if (null != wakelock)
Get the power lock now.
Get the power lock after 2 seconds.
-
Depending on what the phone is set up, there may be software that opens on its own.
-
Method 1: Add a hibernation lock, which must appear in pairs.
Method 2: Set windows properties in the activity layout to control, but be sure to execute it before loading the layout, the limitation of this method is that it is only valid in the activity class, and it will not be effective when the activity exits.
Method 3: Add attributes to the view layout, the advantage of this method is that it does not necessarily have to be on the screen when the activity interface is running, and the view can be set independently after starting.
view's xml layout:
android:keepscreenon="true"
** Do if you keep the screen on:;;
-
Android turning off the screen but not going to sleep should be a system malfunction, the workaround is:
1. Brush the machine under the guidance of professionals.
The specific steps are:
b. Connect the phone with the computer with the original data cable of the mobile phone, and then wait for the flashing assistant to complete the initialization work. After the flashing assistant successfully recognizes the phone, you can click the "One-click Flash" button to start flashing.
d. After selecting the flashing package, click the "Next" button to back up the phone data to avoid data loss. Before the backup starts, allow the flashing assistant to read text messages, contacts, and other records on your phone. Then click the "Flash" button to start the backup and flash, and wait for the flashing to finish slowly.
2. Contact the mobile phone repair personnel to repair the mobile phone.
-
If you have a certain understanding of the hardware architecture of Android phones from the beginning, the designed applications will usually not become standby battery killers, and it is not difficult to design the correct communication mechanism and communication protocol. But if you don't understand and blindly design, you may not be able to.
processor(bp)。AP is an ARM architecture processor used to run Linux + Android system; BP is used to run the real-time operating system (RTOS), and the communication protocol stack runs on BP's RTOS. For non-talk time, the energy consumption of BP is basically about 5 mA, while as long as the AP is in a non-dormant state, the energy consumption is at least 50 mA, and it will be higher when performing graphics limb sleepiness operations.
In addition, the power consumption of LCD is about 100mA when working, and the WiFi is also about 100mA. Generally, when the mobile phone is in standby, AP, LCD, and WiFi all enter a sleep state, and the ** of the application in Android will also stop executing.
Android provides WAKE in order to ensure the correct execution of the key ** in the application
Lock's API, which allows the application to have permission to prevent the AP from going to sleep via **. But if you don't understand the intent of the Android designer and abuse Wake Lock
API, in order for its own program to work properly in the background, prevents the AP from entering the sleep state for a long time, and it will become a standby battery killer. For example, an application from some time ago, such as an application that is still doing this.
First of all, there is no need to worry about AP hibernation and not receiving message pushes. The communication protocol stack runs on the BP, once the packet is received, the BP will wake up the AP, and the wake-up time is enough for the AP to complete the processing of the received packet. Others, such as the AP when the connectivity event is triggered, will also be woken up.
The only question then is how the program executes the logic of sending heartbeat packets to the server. You obviously can't rely on AP to do heartbeat timing. Alarm provided by Android
Manager is here to solve this problem. The alarm should be a BP timer (or some other chip with a quartz clock, not so sure, but definitely not an AP), and when triggered, the AP should be woken up to execute the program**. Then wake
What is LockAPI used for? For example, the execution process of key logics such as the heartbeat packet from the request to the return of the memory, such as disconnection and reconnection, and re-login, requires wake
lock to protect. As soon as a key logic is executed, the wake should be released immediately
locked. The interval between heartbeat requests is 5 to 10 minutes, and it basically does not consume much power. Unless the network is unstable and frequently disconnected and reconnected, there are not many ways to do that.
No harm to the computer. In the standby state, only the individual fans and power indicators are working, and the other parts are powered-on but not working, so it is the same as powering off when the power is off. >>>More
Distract myself, at home I will pretend to be stupid and say stupid things to make everyone laugh, and I will laugh at the same time >>>More
I'm wandering outside, my heart is very chaotic, and when I'm very upset, I call my relatives in my hometown to hear about their recent situation. Or go for a walk outside. Look at the busy pedestrians and the lush vegetation and delicate flowers. The mood will calm down.
Will go out on a trip and enjoy the scenery. Go out to dinner with a few good friends, talk to each other, and think about how to continue with the change. If you are at home, you will watch a movie by yourself, you will go home to accompany your parents, and talk to your parents about why you feel confused, how to live, and some questions about your mentality.
When you are confused, you must first figure out what you are doing this for, and then find a way to solve the situation. >>>More