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
9
votes
2 answers

PARTIAL_WAKE_LOCK vs SCREEN_DIM_WAKE_LOCK in download thread

I have a service that spawns a download thread that downloads sometimes large files. I realized that as soon as the phone went to sleep, the download thread would slow down significantly, then stop. The obvious remedy, a wakelock. So I would think…
Jonathan S.
  • 1,540
  • 1
  • 15
  • 26
8
votes
4 answers

Bring app to front, turn on display and unlock from AlarmManager?

I want to turn on the display, unlock the phone and bring my app to the front, when the alarm I've set activates. public class CountDownAlarm extends BroadcastReceiver { public CountDownAlarm(){ } public CountDownAlarm(Context context, int…
thomas.fogh
  • 369
  • 1
  • 4
  • 17
8
votes
7 answers

Help with PROXIMITY_SCREEN_OFF_WAKE_LOCK in Android

I've enabled the proximity wakelock in my app, and it turns off the screen when the proximity sensor detects something. But there is a problem when the screen wakes back up -- it goes to the lockscreen, not my app. This happens regardless of the…
user496854
  • 6,461
  • 10
  • 47
  • 84
8
votes
3 answers

Android AlarmManager not working while phone asleep

I've got a problem with AlarmManager. In short, I plan an alarmManager : Intent intent = new Intent(context, MyActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); AlarmManager alarmManager =…
mcourpot
  • 315
  • 1
  • 4
  • 15
8
votes
2 answers

Battery optimizations (wakelocks) on Huawei EMUI 4.0+

Good day, situation: I'm developing Android application that serve as sport tracker/navigation app - so it require permanent connection to GPS and also permanent awake device. Recording is done every second. Current solution working for years is…
Menion Asamm
  • 984
  • 11
  • 19
8
votes
1 answer

Is Android's Wakelock a necessity for background services?

I am writing a long-running background service that collects and analyzes device data. To do this I start a service, the service spawns a thread and the thread does the data collection / analysis. From my reading I have learned that if I want the…
neonDion
  • 2,278
  • 2
  • 20
  • 39
8
votes
2 answers

How to wake up Android Wear when it is in sleep mode?

When Android Wear goes to sleep mode (screen dimmed), some parts of my code are not executed. I use Timer in background service to trigger some actions, such as sending data from wear to mobile, but the data is not sent. It is sent when I tap the…
taingmeng
  • 119
  • 1
  • 6
8
votes
4 answers

What does "PowerManger.FULL_WAKE_LOCK is deprecated" mean?

I have this code: wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "MyWakeLock"); And the FULL_WAKE_LOCK is crossed out and it's saying…
silvia_aut
  • 1,481
  • 6
  • 19
  • 33
7
votes
0 answers

How youtube is preventing browser to sleep on iPhone?

Environments iOS 14.4.2 (safari) chrome 91.4472.80 As I was trying to find a way to prevent my iPhone going to sleep while a browser page is opened, I found 3 ways. use Screen Wake Lock…
kukrt
  • 2,117
  • 3
  • 21
  • 32
7
votes
1 answer

Stuck partial wake locks - AudioMix

First of all, I'm not really sure if this is the right place to report this issue but can't find any info or any kind of documentation anywhere. Couple days(maybe weeks) ago Android Vitals started to alerting us about "Bad behaviour" in the Google…
7
votes
3 answers

Wake locks android service recurring

I have this application that needs to run a service (background) that beeps periodically. The phone needs to beep the entire day for 5 seconds every one minute (used a handler in the service). I have implemented this service which does this…
i_raqz
  • 2,919
  • 10
  • 51
  • 87
7
votes
2 answers

Beginner questions: Wakelocks

I am new to the notion of WakeLock and need your help. Questions: I assume WakeLock to be some type of lock which when held by the executing code prevents the device from sleeping. What if the device is already in sleep/standby mode, will the…
Manish Khot
  • 3,027
  • 2
  • 29
  • 37
7
votes
2 answers

Android FULL_WAKE_LOCK is deprecated but PARTIAL_WAKE_LOCK is not deprecated

Here i mentioned the code for waking up the screen. i want the code is listen still the app is closed and the cpu is cleared and user can click the power button when ever my screen is unlock the app is sync like whatsapp. PowerManager pm = …
KOUSIK daniel
  • 305
  • 1
  • 3
  • 11
7
votes
3 answers

Wakelock and wifilock not working

I have read plenty of tutorial and posts here on SO regarding the use of WakeLock and WifiLock, but still didn't get to a solution of my issue. I'm writing an app that has, when you start it, the only effect of creating and starting a (foreground)…
Cristiano Zambon
  • 466
  • 5
  • 14
7
votes
2 answers

StandBy like activity

I would like to create a StandBy activity for my device, and so far I created an activity that when is called will turn off my display. The code is the following: public class MainActivity extends Activity { private SensorManager…
axl coder
  • 739
  • 3
  • 19
1 2
3
35 36