Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Want to improve this question? Update the question so it focuses on one problem only by editing this post .

Closed 8 years ago .

WakeLock is a mechanism to keep the device on, as written here and here

It is used for example when you need to do things even when the device seems to be asleep, like downloading files from the internet.

Wakelocks should never be used unless you really need them. The reason is that they consume more battery, and if you have a bug that won't release them when needed, your app will keep consuming the battery of the device. There are even apps to detect such problematic apps (like "wakelock detector") .

Also, a small tip for people who just wish to let the screen stay on (as long as the app is shown): you don't need (and you shouldn't need) the wakeLock permission. Instead, you should just set " android:keepScreenOn="true" " on the layout of the current activity. More about this is talked about on the lecture "Coding for Life -- Battery Life, That Is" (presentation here )

Another way of keeping the screen on programmatically is getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); as indicated in developer.android.com/training/scheduling/wakelock mtsahakis Oct 20, 2019 at 15:08

You can use a wakelock for keeping the screen turned on - you can see an example in this code .

If you want more information, you have to specify your question.

thanks for the reply. I think this wake lock is used for making device screen stay on when huge data is fetching from server. am i correct ? java dev Mar 12, 2013 at 4:37 That would probably be the main use for the function, yes. Other than that, it seems that wakelock is not a thing that is supposed to be used a lot, because it drains the phone's power a lot. Loyalar Mar 12, 2013 at 7:31 acctually , wakelock should not be used to let the screen on, at least on most cases. see my post below: stackoverflow.com/a/22294934/878126 android developer Mar 10, 2014 at 8:06

A wake lock is a mechanism to indicate that your application needs to have the device stay on.

Any application using a WakeLock must request the android.permission.WAKE_LOCK permission in an <uses-permission> element of the application's manifest. Obtain a wake lock by calling newWakeLock(int, String) .