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

Allow wifi data while sleeping and wake device

I searched and was not able to find the answer to this question. I am working on app that will run all the time. I am using wifi and everything works fine until the device sleeps. One device sends out multicast packets and the other one should…
Mlove
  • 203
  • 1
  • 3
  • 14
0
votes
1 answer

Android service destroy after lock screen

I am using MediaBrowserServiceCompat in my app to play music. I am also starting service with startService method within the service and also using startForeground with notification as well as using wakelock require. But still my service is being…
0
votes
1 answer

Music streaming, Google Developer Console warning: hanging partial wakelock

I have built an online clock radio for Android which also features an integrated music player that works as a foreground service with notification, and it has its own wakelocks - acquiring when service is started and releasing when the user presses…
Ben
  • 265
  • 3
  • 13
0
votes
0 answers

Run a TimerTask or a Handler ALWAYS correctly

I have a problem (that's why I'm here :P): I am running a TimerTask and/or a Handler. They should do something every second, no matter if the screen is on or not (standby). The problem is, after some time (2 to 10 hours) this process becomes weird…
Antonio Vlasic
  • 337
  • 3
  • 15
0
votes
2 answers

Will wakelock + handler allow the device to stay awake?

I am currently working on an app that starts an activity every 30 minutes using a Handler & WakeLock. But I was wondering as to the reliability of this method. I did check this post, but it doesn't seem to answer my question. Here is the code I'm…
user9050166
0
votes
1 answer

How to keep screen state with using Wakelock?

I used Wakelock in my application for fire CPU on when the device went to sleep but i don't want to turn on when screen is off, i mean, i want to keep state of screen and just turn on cpu for my background works. I used below code but in some of…
Fahim
  • 384
  • 5
  • 20
0
votes
0 answers

wakelock fails to keep service alive

I am implementing simple timer and I require it to perfectly measure time. Problem is that even using foreground, START_STICKY and wake lock when timer is started somehow time measuring is killed after some time when phone is not used. I assume it…
kolboc
  • 805
  • 1
  • 8
  • 22
0
votes
1 answer

Background service for continuous location update using fusedlocationAPI

following service is created to continuously update user location. User's location has to be tracked even app is in background, device is idle or screen is off or application is removed/killed from recent list. But somehow this code doesn't work.…
0
votes
2 answers

Android wakelock question

Could someone please show me a sample code snippet where you use two buttons; one to turn off and one to turn on the screen. I cant get it to work. Thanks!
Johan
  • 2,149
  • 4
  • 21
  • 18
0
votes
2 answers

Type of wakelock for waking cpu

I have got an alarm manager and I am working with some tasks in background with alarm managers. I use wakelock for waking CPU in order to finish my background work which causes the error below. I have searched and found that a type of wakelock must…
Fahim
  • 384
  • 5
  • 20
0
votes
0 answers

Beacon connectivity not working when app is in sleep mode

I am working on ibeacon and it is working perfectly fine when app is in foreground or when device is awake but app is in background. The issue is when device goes to sleep mode. iBeacon default methods gets stopped and start working as soon as…
Harneet Kaur
  • 4,487
  • 1
  • 16
  • 16
0
votes
1 answer

Stop iPhone from going to sleep while running A-Frame web app?

Bear with me if this is a stupid question, I'm very new to AFrame and VR, but also programming in general. What I have gathered from google searches and the AFrame source code, is that Wakelock is built in. Great! Does this mean that while using my…
Harry
  • 35
  • 6
0
votes
0 answers

Force network up when handset wakes up on alarm

The following code sets up a repetitive alarm to send a heartbeat to a server every five minutes. if (!isHeartBeating(context)) { alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent alarm_intent…
juan noguera
  • 135
  • 2
  • 3
  • 10
0
votes
1 answer

Android doze mode and foreground service

I read many questions here about doze mode like Android doze mode, Android N Doze mode - how to keep background download and processing?, Wakelock and doze mode and many others. But in many replies, opinions is different. I can't test it by myself…
kara4k
  • 407
  • 5
  • 11
0
votes
0 answers

There is a way to make a timer that works when the Device is locked?

I'm searching a way to make a chronometer that every 5 seconds emits a sound. The problem is that when the device is locked the timer obviously stops (because the CPU goes in sleep mode). My code: final Runnable r = new Runnable() { public void…
JAE
  • 3
  • 4