sleep-mode

How to turn screen off or send device to sleep

ぐ巨炮叔叔 提交于 2019-11-30 14:44:51
问题 I want to send device to sleep or turn the screen off. I have investigated and found this topic: Turn off screen on Android Basically, the are three ways to do it, but I have found problems for the three: a) Choice 1: PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE); manager.goToSleep(int amountOfTime); Problem: It causes FC. I have read I need DEVICE_POWER permissions, but it can't be granted for normal apps. b) Choice 2: PowerManager manager = (PowerManager)

How to keep CPU from 'sleeping' when screen is turned off in Android?

試著忘記壹切 提交于 2019-11-30 13:54:39
问题 I have an application in which I am sending network data over WiFI. Everything is fine until I turn the display off or the device goes to 'sleep'. I'm already locking the WiFi however, it seems to be the case that the CPU speed ramps down when in sleep which causes my streaming to not behave properly (i.e. packets don't flow as fast as I would like as they do when the device is not sleeping). I know that I possibly can/possibly should address this at the protocol level however, that might

How to turn screen off or send device to sleep

泪湿孤枕 提交于 2019-11-30 11:45:57
I want to send device to sleep or turn the screen off. I have investigated and found this topic: Turn off screen on Android Basically, the are three ways to do it, but I have found problems for the three: a) Choice 1: PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE); manager.goToSleep(int amountOfTime); Problem: It causes FC. I have read I need DEVICE_POWER permissions, but it can't be granted for normal apps. b) Choice 2: PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = manager.newWakeLock(PowerManager

Attempting to put Android device to sleep, but the PowerManager does not contain a "goToSleep(long) method

时光怂恿深爱的人放手 提交于 2019-11-30 09:23:39
问题 I am attempting to put a device to sleep and I have found references all over about using the PowerManager class's goToSleep(long) method but I do not see it in the documentation and it does not work when I attempt to using it in my code. Android's documentation does not contain a goToSleep method that I could see. My Code: private void sleepDevice() { try { PowerManager powerMgr = (PowerManager) getSystemService(Context.POWER_SERVICE); long time = 1000; powerMgr.goToSleep(time); } catch

Java Thread.sleep() on Windows 10 stops in S3 sleep status

戏子无情 提交于 2019-11-30 01:23:06
问题 There's a desktop application that uses Thread.sleep() to achieve long (minutes or hours) delays. This same application has been working fine from Windows XP through (at least) Windows 7. The application calculates how far in the future it needs to do something, then hits a Thread.sleep(msToWait). This has been working fine, even if the system happens to go into S3 sleep state during the wait. As of Windows 10, though, the code after Thread.sleep() does not execute "on time" if the machine

Enable iPhone accelerometer while screen is locked

巧了我就是萌 提交于 2019-11-28 11:11:21
So apparently it is possible to keep the processor going processing stuff while the screen is locked, as indicated here: Running IPhone apps while in sleep mode However, after testing with the example code, UIAccelerometer will just stop giving value as soon as the device is locked pronto. Is there a way to force otherwise? There was a bug in iPhone OS prior to 3.1.2 that caused the accelerometer to stop returning values as soon as the screen was blanked. You may be running into this same issue. I filed a bug with Apple about it and they fixed it in 3.1.2. One trick I use in an app is to

Android - How can I wake up the phone from a hard sleep to take a picture?

人走茶凉 提交于 2019-11-28 06:36:43
I want to take pictures from the Android device's camera periodically over a matter of hours, to create a time lapse video effect. I set an Alarm Manager with an AlarmManager.RTC_WAKEUP flag set to start up a service every few minutes. The service holds a partial wakelock, does some work, and then calls a Broadcast Receiver through the Alarm Manager which starts up an Activity. The activity is created (or is resumed), turns on it's own wakelock, and sets up the camera preview surface. Once the surface is setup the SurfaceHolder listener's surfaceChanged() method is called, which finally takes

When does android device go to sleep mode?

半城伤御伤魂 提交于 2019-11-28 06:25:00
I was searching SO and web but i couldn't find sufficient answer for my particular question. Ok here we go: Every user can modify screen timeout on android. (when screen turns off when its idle for __ seconds/minutes - users choice ). But user can modify ONLY screen timeout and not when device goes actually to sleep. I found here what happens when device goes to sleep: (Really nice answer by CommonsWare) Android Sleep/Standby Mode Ok my question is simple. How do i know when my phone will go to sleep? Will it go to sleep immediately after turning screen off? Will it stay "awake" a while after

Can't catch sleep/suspend messages (winXP)

微笑、不失礼 提交于 2019-11-27 16:45:57
问题 My app needs to block sleep/hibernate mode. I have the code in place, but after successfully catching the WM_POWERBROADCAST message, neither PBT_APMQUERYSUSPEND nor PBT_APMQUERYSTANDBY are being caught successfully. Interestingly, the PBT_APMRESUMECRITICAL and PBT_APMRESUMEAUTOMATIC messages are being caught by my app. Bottom line question: is there any reason why my app would fail to catch the standby/suspend messages, but succeed in catching the resume messages? This Q&A [stackoverflow.com]

How can I know when Windows is going into/out of sleep or Hibernate mode?

半腔热情 提交于 2019-11-27 13:34:18
Is it possible to subscribe to a Windows event that fires when Windows is going into or coming out of Sleep or Hibernate state? I need my application to be made aware when the computer is going to sleep to do some cleanup and avoid timing issues when it comes out of sleep. Microsoft.Win32.SystemEvents.PowerModeChanged event will give you this information. This event is available in all variants of the .NET framework released by Microsoft so far. In .NET, use the PowerModeChanged event. In Win32, use the WM_POWERBROADCAST message. You can monitor Win32_PowerManagementEvent WMI event Not sure