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
5
votes
1 answer

What events can wake up a sleeping Android device?

I am writing a Android client app which keeps receiving push notifications from a server using HTTP long-polling(Comet). I don't want to always keep WakeLock since it will drain battery, but I need to make sure the device can receive notification…
bhh
  • 105
  • 2
  • 5
5
votes
2 answers

Does service.startForeground imply wakelock?

Question I am wondering if we need to aquire the WakeLock or if the service.startForeground() command does that anyway for us? I didn't find anything in the documentation. Goal We want to remove unnesessary stuff which might slow down the service…
hb0
  • 3,350
  • 3
  • 30
  • 48
5
votes
3 answers

How to release a wake lock?

I am setting a wake lock using wl.acquire(). This works fine. I need that wake lock as long as my application lives, so calling release() can only be done when the application is left. Do I have to call release() somewhere? For example in onStop()?…
AndyAndroid
  • 4,039
  • 14
  • 44
  • 71
5
votes
1 answer

Android VoIP application: PARTIAL_WAKE_LOCK vs ignoring Battery Optimizations (doze whitelisting)

I'm working on a Voice over IP (VoIP) application using the SIP protocol which requires the application to be listening to incoming calls. This means the application must not sleep or die. For old code, it seems the way to do this is to acquire a…
Emmanuel
  • 16,791
  • 6
  • 48
  • 74
5
votes
1 answer

Is there any way to receive a CPU wake event in Android?

I'm trying to reduce power consumption in an Android application which must do some menial data processing periodically, but not so urgently that it needs to trigger wakes itself. Is there any way to receive an event when another app or process is…
KG6ZVP
  • 3,610
  • 4
  • 26
  • 45
5
votes
3 answers

Android isScreenOn Nullpointerexception

i used this code to keep the screen on on Android 4.4.2. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
Fabian
  • 167
  • 1
  • 9
5
votes
2 answers

PowerManager.WakeLock on Android Devices

i am trying to implement an WakeLock in my Android App. I have the following code in my onCreat(): pm = (PowerManager) getSystemService(Context.POWER_SERVICE); myWakeLock = pm.newWakeLock(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,"WakeLock for…
Benedikt Bock
  • 1,007
  • 15
  • 37
5
votes
2 answers

android background location updates and wakelock

I'm working on an android app where I need to get location updates in the background for an extended period of time using the GPS provider, so I need the location udates to occur when the user is no longer interacting with it. I did some testing of…
user1057118
  • 51
  • 1
  • 5
5
votes
3 answers

Unity3D Android Lockscreen not shown when screen times out. (Wakelock?)

I am building an android app using Unity and it is coming along very well. However, I'm having an odd issue relating to the screen timing out and the lockscreen not showing. What Should Happen User stops playing Screen Times out and turns…
Khalos
  • 2,335
  • 1
  • 23
  • 38
5
votes
2 answers

How to wake up android and show the activity?

Please, help me. I have a broadcast reciever: public class BrcRec extends BroadcastReceiver{ public static WakeLock wakeLock; @Override public void onReceive(Context context, Intent intent) { PowerManager pm = (PowerManager)…
user2254276
  • 51
  • 1
  • 3
5
votes
1 answer

Wake up Android Phone/tablet?

I've got a push notification-app, is there any way to wake up the screen (just make it light up) whenever I receive a push notification? if you want some code just let me know! and Thank you for your answers!
intINk
  • 129
  • 1
  • 12
5
votes
0 answers

How to use wake lock for android mediaplayer?

I'm trying to play a playlist with the android media player. When one track ends; i stop the media player and init it again with the new one. Everytime i init the player I set the wake lock with this…
syloc
  • 4,569
  • 5
  • 34
  • 49
5
votes
0 answers

Android disable proximity sensor during phone call

I have an app that places a phone call and then switches back to my activity while the phone call is happening. The problem is, if the user puts their hand near the proximity sensor, then the screen turns off. Is there a way to disable the…
Chris Feist
  • 1,678
  • 15
  • 17
4
votes
3 answers

Android: How to wake WIFI (or 3G) from AlarmManager?

I have this application that needs to pull data from a server every 30 minutes, after a lot of search I reached this solution: 1- using AlarmManager to notify the application each 30 minutes instead of keeping the service running in the…
Kumait
  • 702
  • 8
  • 15
4
votes
2 answers

Android keep screen on on Samsung devices

I have a streaming app and I want to avoid that the screen turns off while streaming. It works on most of my devices but it doesn't on certain Samsung devices (Samsung Galaxy S21 Ultra, Samsung Galaxy S10 etc). What I tried so far: Add this to the…
grill2010
  • 574
  • 6
  • 23