wakelock

What exact functionality stops working if a wake lock is not acquired and the device goes into sleep?

末鹿安然 提交于 2019-12-10 23:36:16
问题 The last couple of days I've been trying to figure out which functionality in a service (background and foreground) stops working when the device falls into sleep without a wake lock. All the documentation only says that a wake lock "keeps the CPU from shutting down", but every single functionality I've tested kept working without a wake lock if I turned the screen off and unplugged the device. I've also checked via adb if another application is holding a wake lock, but the wake lock count is

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

社会主义新天地 提交于 2019-12-09 11:32:48
问题 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 screen to wake it up. I also try to use Timer trigger a notification with vibration when the screen is off, but it doesn't appear until I tap the screen. In debug mode (either Bluetooth or USB), data sending and notification work fine. I suspect this

Wakelock and wifilock not working

会有一股神秘感。 提交于 2019-12-08 17:41:35
问题 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) service. This service run two threads that are an UDP broadcast listener (using java.io) and a TCP server (using java.nio). In the onCreate of the service I acquire a wakelock and a wifilock, and I release them in the onDestroy. Everything works

How to keep application awake in background

痴心易碎 提交于 2019-12-08 06:36:01
问题 I program an application, which is connected to bluetooth device and used in a car (in the background) and navigation (or something else) in the foreground. But on android 7+ (maybe also 6), application go to sleep after some time. When I'm trying to take picture from camera the "sleep mode" is immediately and my app is sleeping now (no bluetooth connection, no notifications) - just dead app. I must go to recent apps -> click on my app and this make the "wake up". Bluetooth is now connecting

Check for wifi networks signal in sleep mode

℡╲_俬逩灬. 提交于 2019-12-08 05:00:55
问题 My objective is to be able to scan changes in Wi-Fi networks (mainly to check what networks are available). Right know I'm doing it by registering a reciever: registerReceiver(wifiReceiver, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION)); where WifiReceiver is my BroadcastReceiver . The problem is that it works only when the phone is on. As soon as it goes to sleep mode (either by pushing the power button or after some time), the receiver stops receiving. I already acquired a wake lock in

Does service.startForeground imply wakelock?

随声附和 提交于 2019-12-07 15:55:31
问题 Question I am wondering if we need to aquire the WakeLock or if the service.startForeground() command does that anyway for us? I didn't find anything in the documentation. Goal We want to remove unnesessary stuff which might slow down the service start as we want to start capturing the sensor data as soon as possible and as the service might be restarted frequently. Context We're developing an Android library to capture sensor data with ~ 200 Hz for up to a couple of hours (research

android的PowerManager和PowerManager.WakeLock

孤街醉人 提交于 2019-12-07 11:11:20
PowerManager.WakeLock   PowerManager.WakerLock是我分析Standup Timer源代码时发现的一个小知识点,Standup Timer 用WakeLock保证程序运行时保持手机屏幕的恒亮(程序虽小但也做得相当的细心,考虑的很周到)。PowerManager 和PowerManager.WakerLock7用于对Android设备的电源进行管理。    PowerManager :This class gives you control of the power state of the device.    PowerManager.WakeLock : lets you say that you need to have the device on.   Android中通过各种Lock锁对电源进行控制,需要注意的是加锁和解锁必须成对出现。先上一段Standup Timer里的代码然后进行说明。 代码 private void acquireWakeLock() { if (wakeLock == null ) { Logger.d( " Acquiring wake lock " ); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);

How to keep application awake in background

一世执手 提交于 2019-12-06 15:56:47
I program an application, which is connected to bluetooth device and used in a car (in the background) and navigation (or something else) in the foreground. But on android 7+ (maybe also 6), application go to sleep after some time. When I'm trying to take picture from camera the "sleep mode" is immediately and my app is sleeping now (no bluetooth connection, no notifications) - just dead app. I must go to recent apps -> click on my app and this make the "wake up". Bluetooth is now connecting to device again. But I can't still check if the app is sleeping or not. So, how to keep app awake also

Recognize volume button presses when screen is off Android

霸气de小男生 提交于 2019-12-06 07:18:05
问题 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 activity running using a PARTIAL_WAKE_LOCK. My app is a basic one that shouldn't use too much battery, but I'm concerned that using a PARTIAL_WAKE_LOCK might drain the battery (which defies the purpose of recognizing button presses when the screen is

How to wake up an Android on incoming data

人走茶凉 提交于 2019-12-06 07:06:31
问题 I want an Android service, which is listening for data (I have tried TCP and UDP) to wake up the service/phone when data arrives. Currently the phone stays asleep when IP data arrives and that data is lost. Is this normal for Android? I see sleeps of 2+ hours several times a day, and 7+ hour sleeps when I am asleep. Does GCM provided a solution which wakes up a service/phone when a message arrives. I need messages to be displayed within a few seconds of them being sent from the server. Can