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

Detect Device Wakeness In Android

I'm trying to create a service that run in background in android.. That service should work only when the device is on sleep (Means that screen is off).. I think that can be done using a service but I don't know how to detect if the phone is awake…
Muhammad Ashraf
  • 1,252
  • 1
  • 14
  • 32
0
votes
0 answers

Wakelock works only when screen turned on

many things has been written about wakelocks in Android. I'm using wakelock this way: PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); partialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,…
skywall
  • 3,956
  • 1
  • 34
  • 52
0
votes
1 answer

Error on starting activity from background

I have been searching out a lot of things to sove my problem but none of the solutions I found worked in my case :'( Here is what I am trying to do: When the screen is off, my BroadCastReceiver detects it. Once screen_off is detected, acquire…
DVN
  • 1
  • 2
0
votes
0 answers

WakeLock Release android

WakeLock wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyCpuLock"); wl_cpu.acquire(8000); wl_cpu.release(); Good day everyone! I have simple question here. I am using the above code as my wake lock in case user receive notification, and…
JayR
  • 441
  • 1
  • 4
  • 16
0
votes
3 answers

Job manager in Android

I have a task to run several different jobs in Android app. Each job is long-running and cosumes network, database and file system much. Each job can be run manually by user or scheduled by AlarmManager. It is very important that each job runs till…
afrish
  • 3,167
  • 4
  • 30
  • 38
0
votes
1 answer

AlarmManager vs Service for db and FTP connection. Which and how to use?

My question is rather simple but might come with a complex answer. I'm making an App that checks on an online mysql db (via a php script on the website) for new updates. Sometimes this updates will tell the App it has to download form a FTP…
Luciano Stupenengo
  • 183
  • 1
  • 1
  • 12
0
votes
2 answers

For which kinds of work I need to use CPU WAKE_LOCK in Sleep Mode?

For which kinds of work I need to use CPU WAKE LOCK ? For example in Sleep Mode I am using TelephonyManager getCellLocation(), should I use PARTIAL_WAKE_LOCK in this case or not? I didn't find this info in the documentation. P.S. TelephonyManager…
pvllnspk
  • 5,667
  • 12
  • 59
  • 97
0
votes
2 answers

Allowing service to run permanently in background

I have a messaging app based on webscokets that relies on a background service to send and receive messages. Once the service is started, I need it to run indefinitely in the background, even when the app closes as well as the phone goes into sleep…
Sauron
  • 6,399
  • 14
  • 71
  • 136
0
votes
0 answers

How to prevent Android app from doing things at night with wake lock off?

When the activitiy is in the foreground, my app is doing things at night even though the phone should be sleeping. Wake log permission is NOT set. But in the…
Oliver Hausler
  • 4,900
  • 4
  • 35
  • 70
0
votes
1 answer

Device not locked after WakeLock

I have some problem with a code which is called by AlarmManager. I call a wakeLock to do a task in order to transfer data to a web services My wakelock is quite well executed and after my upload, i call the method release But after that, my device…
Minifish
  • 41
  • 5
0
votes
1 answer

Android Wear app that crashes when I release wakeLock

I have an extremely simple Android Wear app that basically is just one button on the mobile device that I want to use to turn the display of my Android Wear device on and off. I have the application sending messages to the Android Wear device to…
0
votes
0 answers

Android: React on alarms from AlarmManager in Service

I want to fetch weather information periodically to send it to a smartwatch - even if the phone is in deep sleep. My first aproach was to implement a service, that always runs and uses Handlers with postDelay(). This only worked, when the phone was…
Martin
  • 155
  • 1
  • 8
0
votes
1 answer

Wakelock not working at all

What's missing in here? I want to wake up the device from sleep, but nothing happens. I certainly do not want to prevent sleeping. final Handler handler = new Handler(); Runnable runable = new Runnable() { @Override public…
Shervin
  • 233
  • 1
  • 13
0
votes
1 answer

Broadcast receiver vs activity with alarmmanager

I am using broadcast receiver with AlarmManager, but sometimes it takes lot of seconds to wake up, which causes issue in app functionality PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl =…
Haris
  • 1,822
  • 2
  • 22
  • 44
0
votes
1 answer

Activity start from sleep mode immediately close?

I have an app wich is a kind of alarmclock. I have a weird issue. The principle is simple : The alarmmanager send a broadcast that will start a service and an activity. The service vibrates the phone for 10s and then kill the activity and…
user1391967
  • 497
  • 1
  • 6
  • 13