Questions tagged [powermanager]

PowerManager is a class in the Android SDK that gives control of the power state of the device.

PowerManager is a class in the Android SDK that gives you control of the power state of the device.

Device battery life will be significantly affected by the use of this API. Do not acquire PowerManager.WakeLocks unless you really need them, use the minimum levels possible, and be sure to release them as soon as possible.

You can obtain an instance of this class by calling Context.getSystemService().

The primary API you'll use is newWakeLock(). This will create a PowerManager.WakeLock object. You can then use methods on the wake lock object to control the power state of the device.

Reference page: http://developer.android.com/reference/android/os/PowerManager.html

109 questions
0
votes
1 answer

Keep the screen on in Trusted Web Activity

I want to keep screen on while show trusted tabs. I was override the WebViewFallbackActivity class and inject this code but it's not working: PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); PowerManager.WakeLock wakeLock…
Alireza
  • 209
  • 2
  • 3
  • 10
0
votes
1 answer

How to use WakeLock with "PowerManager.LOCATION_MODE_NO_CHANGE"?

I am trying to use PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.LOCATION_MODE_NO_CHANGE, "My Tag"); mWakeLock.acquire(); in onCreate method of Activity. But it is…
0
votes
0 answers

Android service with a TimerTask and a WakeLock pauses its work when screen is off

Hello to all Android developers, I wish to ask a question about something that drives me mad over the last few weeks and I cannot make it work properly. I have an Android app that runs a service that has a loop in it that runs every few seconds and…
0
votes
1 answer

My background service stops when the screen turns off on my Moto G6

I created an app to work on my Moto G6 android device. Basically, this app that start a local service to periodically access a web site. Everything looks good but when the screen turns off, the service is paused. It become active again when the…
0
votes
1 answer

Android powermanager wakelock issue

I want to set the wakelock time to the "unlimited" time or at least set the time to xx minutes / hours. If I try these code : PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wl =…
itsmebil
  • 155
  • 1
  • 9
0
votes
1 answer

How might work flag, that do not specified in Developer Android Docs?

I reverse engineer one application that turn on / off screen on shake. It uses WakeLock by PowerManager this.mWakelock = this.mPowermanager.newWakeLock(268435466, "ShakeUnlock"); //LockService.java activity Flag that is written here, 268435466. I…
0
votes
2 answers

Wake device on triggering the notification

I have set a reminder in my app, but the screen does not turn on when the notification arises and neither does it pop up. I just get the notification the notification bar. The device should wake up(if locked) or show notification pop up(if…
0
votes
0 answers

how to turn on the android phone screen at the desired time in new APIs (above API 23)?

I am developing a new application that is needed to light up the screen at the desired time and play a sound or alarm along with the notification. this concept is working in APIs below 23 with Wake_lock and some other deprecated methods. but as I…
0
votes
0 answers

how to force turn off device?

currently eclipse/android studio cannot build the app with error: undefined function gotosleep(); PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); pm.goToSleep(100); here in the manifest added:
vims liu
  • 643
  • 1
  • 9
  • 20
0
votes
0 answers

Wifi disabled after entering sleep mode (idle)

I'm building an audio streaming app where the users should be able to listen to their songs while the device is locked (as any other music app). Some users are reporting a problem where the playback is being stopped after 10 to 15 minutes on WIFI.…
0
votes
1 answer

Should we call PowerManger's reboot method in a separate thread?

I need to programmatically reboot an android device, and the PowerManager's reboot functionality comes in handy. My question is: Should reboot be called in a separate thread or is it okay to call it in the same thread?
d3xter
  • 51
  • 5
0
votes
1 answer

no battery detected, empty power_supply and acpi directories

there is no battery detected. there are no forums with the solution. I've edited grub to force acpi and i have nothing listed in proc/acpi/battery or /sys/class/power_supply. i have reinstalled with different distributions, releases, desktop…
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 wake up device when it sleeps

I've already read a lot about this topic on SO. I'm trying to write SIP Client, which of course should accept incoming calls when the device is sleeping. The first thing I've tried was to use these flags in my onCreate method: Window window =…
0
votes
1 answer

Why holding PARTIAL_WAKE_LOCK causing random system crash?

I have an app holding the PARTIAL_WAKE_LOCK on startup and then releasing onDestroy. Randomly it crashes after some time 40min - 2 hours when the device is just left alone/screen is dimmed. After some investigations I found that releasing the wake…