Questions tagged [android-wake-lock]

Refers to PowerManager.WakeLock, a class from the Android SDK belonging to package android.os. Its responsibility is requesting CPU resources in the context of power management. If no wake locks are taken, Android will shut down the CPU.

The Android Operating System uses its own power management scheme, built on top of the standard Linux one. Since it's mobile-oriented, one of its main goals is to avoid wasting CPU cycles (i.e. power) if no application is running.

That's why every application must request CPU resources, using wake locks. If no wake lock is taken, Android will shut down the CPU in order to save power.

Resources:

366 questions
48
votes
2 answers

Does the Android OS release a wakelock if the app or service holding it is killed?

I have question about wakelock. In cases shown below, does android OS release wakelock (PARTIAL_WAKE_LOCK if you need to specify) to prevent wakelock was left acquired and wasting battery until turning power off (not sleep). Case 1-a: App has…
Tomcat
  • 1,405
  • 3
  • 22
  • 37
47
votes
1 answer

Android - Wake Up and Unlock Device

Application description: The application is intended as a safety program for a specific client (not to be deployed publicly). When the application has not detected movement for a certain period of time, the application should sound an alarm and…
Paul Richter
  • 10,908
  • 10
  • 52
  • 85
37
votes
7 answers

Samsung "App optimisation" feature kills background applications after 3 days

We are currently developing an Android app that is a fitness-tracker application. It runs constantly in the background, and it works fine on most devices, but we've been having issues with the application dying completely on some Samsung devices.…
24
votes
9 answers

Android Espresso, Wake up device before test. How to use a custom manifest for test?

I've been writing tests with androids new espresso framework and find that it works well. One annoying thing (not particular to espresso) is that I have to make sure my screen is awake and unlocked for the tests to run. I found a workaround (through…
Matt Wolfe
  • 8,924
  • 8
  • 60
  • 77
23
votes
5 answers

Turn off screen on Android

I am trying to turn on and off the display after a certain action happens (Lets just worry about turning the screen off for now). From what I understand from wake lock, this is what I have: PowerManager pm = (PowerManager)…
thegreyspot
  • 4,079
  • 5
  • 28
  • 34
22
votes
3 answers

Android Bluetooth & WakeLock relationship

I'm working on an Android application that runs in the background and enables support for a Bluetooth accessory. I would like to be constantly listening in the background for the Bluetooth device to try and open a socket to the phone. My question is…
Christopher Souvey
  • 2,890
  • 21
  • 21
21
votes
1 answer

what is the proper, non-deprecated way to wake up the device?

My requirement is: after a GCM message arrives, the device should wake up to display a high-priority notification. The device should turn the screen on. Currently I'm using WakeLock to achieve this. The newWakeLock() method expects a lock level AND…
Droidman
  • 11,485
  • 17
  • 93
  • 141
21
votes
3 answers

Turning on screen from receiver/service

I would like my app to be able to turn the screen on and display my app. Let's say I'm setting an alarm and every hour I want my app to be displayed for 2 mins before the device naturally sleeps. I see that WakeLock (FULL_LOCK) and KeyguardManager…
RuAware
  • 979
  • 1
  • 9
  • 26
20
votes
1 answer

WakeLock finalized while still held error even though I'm releasing it

I have a service that should be run in the background. It starts when my app is open, and ends whenever my app is turned off by the user. Whenever my app is in the background or when the screen is turned off, I still need the service running. I…
David
  • 7,028
  • 10
  • 48
  • 95
20
votes
1 answer

Will a Handler postDelayed not being fired when CPU sleeps?

I have an activity with some Handlers that are being executed at intervals no more than 5 minutes. The activity is launched from a BroadcastReceiver and may be launched with the screen off waiting for the user to grab the phone and get the user…
19
votes
8 answers

How to make android device always in wake mode?

After successful root of device. Now, I need to make device always in wake state i.e. always visibility of UI and no black screen or any daydream screens. To do so I think I've to accomplish following : No lock screen - turned off Sleep set to…
Chitrang
  • 5,097
  • 1
  • 35
  • 58
18
votes
2 answers

Android: Foreground service vs. wakeLock

I am relatively new to Android, so what I am asking may seem obvious (although I have read all the similarly titled questions, and have searched extensively). I need to monitor the accelerometer continuously for long periods. Two approaches have…
Doug
  • 181
  • 1
  • 4
15
votes
0 answers

How to enable wake on usb (remote wakeup) in android?

I have an AOSP tree compiled on my board. I bought a wireless keyboard and connected it to my board via usb port. I expect when the board is in the suspend state, it will wakeup by pressing a key on keyboard. But it is not so. I tried several ways…
Saleh
  • 1,819
  • 1
  • 17
  • 44
13
votes
2 answers

Android - When using LocationManager.requestLocationUpdates, do I need a WakeLock?

My app periodically checks the location using an alarm to a BroastcastReceiver that starts a service. I know I should acquire a wakelock before I start the service but my question is when can I release it? If I release the wakelock after calling…
noah
  • 21,289
  • 17
  • 64
  • 88
13
votes
7 answers

scheduling alarm for every second in android 5.1

I want to run alarm service for every second in my application.It is working fine below 5.1 version. but it is not triggering in 5.1 devices. I am using commonsware wakeful intent service.The logcat message is saying that "Suspiciously short…
Chaitu
  • 907
  • 2
  • 13
  • 27
1
2 3
24 25