Questions tagged [wakelock]

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:

534 questions
64
votes
1 answer

BroadcastReceiver Vs WakefulBroadcastReceiver

Can somebody explain what the exact difference is between BroadcastReceiver and WakefulBroadcastReceiver? In what situations would we have to use each Receiver class?
user2107111
  • 735
  • 1
  • 6
  • 10
51
votes
3 answers

Keep a Service running even when phone is asleep?

I have a Service in my application which is designed to run every 10 minutes. It basically checks up on our servers to see if everything is running properly and notifies the user of any problems. I created this application for internal use at our…
PaulG
  • 6,920
  • 12
  • 54
  • 98
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
7 answers

OnPause and OnStop() called immediately after starting activity

I have an activity that needs to turn screen on(if offed) when it is started. So in onCreate, I have: this.getWindow().setFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |…
Haris
  • 1,822
  • 2
  • 22
  • 44
40
votes
1 answer

Android persistent socket connection rules

I have been doing some testing for a custom push notification solution for Android devices using persistent sockets. I would like to share my findings and validate the results. Simple Description The applications runs a foreground service and…
Alex
  • 2,033
  • 1
  • 24
  • 40
30
votes
2 answers

Light up screen when notification received android

I have a service running for my application to send notification every hour. This is working fine as i heard a sound and a vibration every hour because of my notification but i also want that my notification light up my screen as well. But i am…
Pirate
  • 545
  • 1
  • 6
  • 15
30
votes
4 answers

Android - Turn off display without triggering sleep/lock screen - Turn on with Touchscreen

I have been trying to find a way to turn off the display, and wake up from the user touching the touch screen. The device is in an embedded environment where the device is a tablet and the user does not have access to anything except the touch…
NebulaSleuth
  • 833
  • 1
  • 7
  • 18
29
votes
8 answers

How can I see which wakelocks are active

For some reason my Android phone won't go to sleep. I assume that a wakelock is keeping it awake, but there is no way to tell which wakelocks are active. The running services doesn't list anything suspicious, and certainly nothing different from…
Timmmm
  • 88,195
  • 71
  • 364
  • 509
24
votes
5 answers

Foreground service not receiving location updates in Android 7.0+ when screen is off

I am trying to create an Android application that continuously logs device location data in realtime while the device screen is off. My code works correctly with Android 6.0 and earlier but it seems that Android 7.0+ breaks my app. I have…
Joshua W
  • 4,973
  • 5
  • 24
  • 30
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
23
votes
3 answers

WakeLock finalized while still held

The pm and keepScreenOn variables are globally defined. I grab the PowerManager.WakeLock in my OnCreate method: pm = (PowerManager) getSystemService(Context.POWER_SERVICE); keepScreenOn = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_LOCK,"tpd"); in my…
Tim Daly
  • 231
  • 1
  • 2
  • 3
22
votes
4 answers

Correct pattern to acquire a WakeLock in a BroadcastReceiver and release it in a Service

Even after a lot of research I am still not completely sure if the way how I implement a WakeLock for a Service started by a BroadcastReceiver is correct - even though it seems to work fine. The broadcast receiver gets intents sent to it from an…
Torsten Römer
  • 3,834
  • 4
  • 40
  • 53
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
17
votes
2 answers

Service, WakeLock

I am bit confused after going through the questions & answers in Stackoverflow about WakefulIntentService. I just would like to get some knowledge on this topics to make sure my understanding is correct, please feel free to correct me, if I am…
Ramesh Sangili
  • 1,633
  • 3
  • 17
  • 31
17
votes
4 answers

How to make the Android device hold a TCP connection to Internet without wake lock?

I want my application to be connected to server though the mobile connection, yet allowing the device to go into sleep mode. I expect it to wake up when IP packates arrives. How can this be done? How to receive "interrupts" from the Internet without…
Vi.
  • 37,014
  • 18
  • 93
  • 148
1
2 3
35 36