Questions tagged [android-wake-lock]

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:

366 questions
0
votes
1 answer

Sensor Background Service wakelock

I am working on an app that runs a background services which reads accelerometer (and also sometimes, gyroscope) data in the background continuously. I use partial wake lock but there's battery drain. Is there any way I can reduce or minimize the…
0
votes
2 answers

Acquire wake lock, release it and acquire it again while the phone is sleeping

I think this is pretty much the standard case already described in other SO question but I still need a clarification on this matter: So I have an Android app with an Actvity and a Service. The Activity is not of interest but the Service. The…
Anton Sarov
  • 3,712
  • 3
  • 31
  • 48
0
votes
2 answers

Android Background Service with PARTIAL_WAKE_LOCK

So... I have a service that spawns a thread that is listening to data from a device via the device's wifi network. All works well, except that the service seems to pause when the the device is put to sleep. I've tried PARTIAL_WAKE_LOCK and WIFI_LOCK…
KMLong
  • 8,345
  • 2
  • 16
  • 19
0
votes
1 answer

android broadcasts and wake locks synchronization

I have a service A, which is started by WakefulBroadcastReciever from AlarmManager. Service A follows a standard pattern - performs a computation, then sends local broadcast to inform the system about the results, then calls…
0
votes
1 answer

NotificationListenerService and keeping device awake during work

I'm extending the NotificationListenerService in order to catch notifications being posted to the device. This has been working perfectly fine without doing anything special (like using wakelocks). I used to use a background thread to do some work…
0
votes
0 answers

Using WakeLock versus AlarmTimer in 10 hour background service

I have a background service that runs for a period of about 10 hours. During this period it acquires information from one of the phone's sensors (about 300 TIMES PER SECOND), processes the information, and uploads the processed information to a…
0
votes
1 answer

Implementing awake lock on a service

I am calling a service from an AlarmManager onReceive, below is the implementation. I want to know if this implementation of a wake lock is fine and will it suffice my needs? This is the onStart function in my Service Class: @Override public…
User3
  • 2,465
  • 8
  • 41
  • 84
0
votes
1 answer

PowerManager and PARTIAL_WAKE_LOCK behaviour

I use an alarm to take pictures at regular time intervals. I use a BroadcastReceiver as follows: @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Capturing pic"); PowerManager pm = (PowerManager)…
user2923045
  • 369
  • 2
  • 6
  • 16
0
votes
1 answer

Starting android default music player in background

I have built a small remote control service in my app to control the default music player from within my app. I can play, pause, skip and move backwards using the method private void remoteControl(String CMD) { Intent i = new…
0
votes
0 answers

Preventing lock screen from showing on wake-up?

I'm building an alarm app. I have it so a broadcastreceiver acquires a wakelock and starts the alarm activity. These are the flags I'm using: Wakelock: PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE); WakeLock wakeLock =…
Huy T
  • 1,273
  • 1
  • 11
  • 21
0
votes
1 answer

How to unlock device when service call

In my application, user starts the service it is open and it is called every 5 minutes. it works fine. But I want to unlock automatically (call WAKE_LOCK ) whenever the service is called i.e. every 5 minutes. How can I achieve this? Any body…
Android_dev
  • 320
  • 1
  • 7
  • 26
0
votes
0 answers

Android app slowdown despite wakelock on USB disconnection

I am making an application that does some audio processing and plays it back in real time. The issue I'm facing is that the application works just fine when the phone is connected to the computer with a USB cable, but the audio starts to skip and…
Anuj Jain
  • 315
  • 1
  • 15
0
votes
1 answer

ADB wifi unreachable when it looses connection in device with wake lock (CPU only)?

I am using wake lock on my Nexus 4 to force it to stay awake (I am using wake lock with CPU only option). However, after sometime, ADB wifi looses connecting and I am unable to reconnect to it again unless I turn the screen back on. Does anyone know…
22332112
  • 2,337
  • 5
  • 21
  • 42
0
votes
1 answer

Switch on screen and let default display timeout take over?

I'd like to switch on the screen from a service and immediately let the default system timeout take over (i.e. not hold a wakelock for a specific time, but just hand over control to the system). I've tried WakeLock.acquire() followed immediately by…
Nick
  • 3,504
  • 2
  • 39
  • 78
0
votes
0 answers

Display goes to sleep after application starts on Android 4.1.x

I've got application running on Android 4.0.4 successfully. However, if I run it on device with Android 4.1.x. it runs (by looking into the logs, I can see OnCreate starts), but displays goes black immediately. If I press power button, I can see…
MartinC
  • 546
  • 11
  • 26