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
4
votes
3 answers

BroadcastReceiver, Service and Wakelock

im receiving an intent in broadcast receiver and then i start service to do more work. now what if the device is sleep and this happen, do i have to get Wakelock (AlarmManger?), and why do i need it? does my service will stop running if the device…
Jimmy
  • 10,427
  • 18
  • 67
  • 122
4
votes
3 answers

AlarmManager and WakeLock

I want to use an alarm manager in my activity. I set up an alarm at the onPause method of main activity like this, Intent intent= new Intent(namaz_vakti_activity.this, namaz_vakti_activity.class); PendingIntent sender =…
Mesut
  • 113
  • 1
  • 1
  • 6
4
votes
1 answer

Does a foreground service need a wake lockt to stay active after screen-off?

In different sources, I read that a foreground service requires a wake lock to stay active after the device goes to sleep. But when I test it by starting a foreground service and turning the screen off while the device is unplugged (both on emulator…
4
votes
1 answer

How to use PowerManager.ACQUIRE_CAUSES_WAKEUP

How can I use ACQUIRE_CAUSES_WAKEUP? ACQUIRE_CAUSES_WAKEUP must be used with another wakelock or you risk an error: java.lang.IllegalArgumentException: Must specify a valid wake lock level. However, FULL_WAKE_LOCK, SCREEN_DIM_WAKE_LOCK, and…
Domen Jakofčič
  • 626
  • 1
  • 8
  • 24
4
votes
2 answers

How to keep android device from sleeping while plugged in

I'd like to keep the screen on whenever one of my Activities are running and the phone is plugged in to a power source. I know that Wakelocks are tricky, so I'm looking for an example or some documentation on how to accomplish this specific goal.
twk
  • 16,760
  • 23
  • 73
  • 97
4
votes
3 answers

Alarm Manager won't work when the app is killed in the background and device is locked

I have been stuck in this situation for a long time... I want to use the alarm manager to show notification at the specific time, and now it worked in the situation listed below: when the app runs in the background, notification will be shown at…
Guomato
  • 91
  • 1
  • 6
4
votes
1 answer

Remove unwanted WAKE_LOCK permission merged from library

I am about to publish an ap and notice that it requires "prevent phone from sleeping" permission which I did not include in my ap manifest. Looking at the aps' manifest-merger debug report, I notice that it's coming from…
4
votes
0 answers

Activity Recognition does not work after phone goes asleep

Disclaimer: this is not duplicate of Activity Recognition stops receiving updates when phone goes to standby(screen off state) because I'm already using that approach and it does not help. Problem: It seems that Activity Recognition service stops…
4
votes
2 answers

Recognize volume button presses when screen is off Android

I am trying to recognize when the user presses the volume rockers when the screen is off to update an activity. From what I've read, BroadcastReceivers (I think) don't work when the phone is asleep, and so the only way to do this is to keep the…
husam
  • 41
  • 2
4
votes
2 answers

Internet connection paused after Android phone lock

I am building application which can get location using NETWORK_PROVIDER periodically in background without using GPS_PROVIDER. I am using ALARM_SERVICE and WakeLock(PARTIAL_WAKE_LOCK). but the problem which i am facing is that internet connection…
Amol Sawant
  • 13,842
  • 2
  • 20
  • 27
4
votes
1 answer

Android TTS + WakeLock

I have an app which is using TTS to read text in an AsyncTask. My problem is when the phone goes to sleep the playback stops. I went through many threads in the topic and everything points towards WakeLock. However I am not able to implement it, no…
Sandor Farkas
  • 153
  • 2
  • 11
4
votes
1 answer

Timer Slows down in Service when device screen lock

I am using a countdown timer in a service.The timer goes on like that 01,02,03,.... Everything works fine.But when the device screen lock the timer becomes slow but still running.I am using the PowerManager but not working.PowerManager only works…
Deepak Sharma
  • 4,999
  • 5
  • 51
  • 61
4
votes
1 answer

wakelock, deep-sleep, and gcm

I've searched a bit but had a question about the true function of the wakelock with GCM. Does the wakelock prevent the device from going into a sleep mode that would prevent the network layer from shutting down -- so it can receive a GCM message…
Geremy
  • 2,415
  • 1
  • 23
  • 27
4
votes
1 answer

Alternatives to Wakelocks?

I'm working on an app which needs to send data to a webserver after every x minutes (where x is a value that can be changed through webserver responses). Right now, I'm using a background thread that sleeps for x minutes and then notifies the main…
SJunejo
  • 71
  • 1
  • 8
4
votes
1 answer

Keep screen on from a service

I would like to know how to keep the screen permanently on from a service. Here is the scenario for the code: User plugs phone into power outlet, Broadcast receiver gets event, start a service that prevent the screen from timing out. User unplugs…
axr 0284
  • 113
  • 1
  • 9