Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of android permission Wake Lock? [closed]

When and why to use the android permission <uses-permission android:name="android.permission.WAKE_LOCK" />. Please provide sample code regarding wake lock.

like image 575
java dev Avatar asked Mar 11 '13 07:03

java dev


People also ask

What is the use of permission in Android?

App permissions help support user privacy by protecting access to the following: Restricted data, such as system state and a user's contact information. Restricted actions, such as connecting to a paired device and recording audio.

What are the wake locks available in Android *?

What are the wake locks available in android Options 1 FULL WAKE LOCK 2 SCREEN BRIGHT WAKE LOCK 3 SCREEN.

What is the purpose of setting the user permission for Access_fine_location?

If your app needs to access the user's location, you must request permission by adding the relevant Android location permissions to your app. Android offers two location permissions: ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION . The permission you choose determines the accuracy of the location returned by the API.

What is Android permission Change_network_state?

permission. ACCESS_NETWORK_STATE. view network connections. Allows the app to view information about network connections such as which networks exist and are connected.


1 Answers

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)

like image 72
android developer Avatar answered Sep 17 '22 13:09

android developer