Questions tagged [android-powermanager]

Tag for Android PowerManager questions - class, that gives you control of the power state of the device.

This class 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.

Useful links

70 questions
1
vote
1 answer

How to keep CPU running while closing screen?

There is a time-consuming task (a Thread) in Fragment. It works fine. But, when I close the screen, I see the CPU not work so that the task cannot work fine. I have use PowerManager in Activity, but not work Fragment too. Also add
zys
  • 1,306
  • 3
  • 18
  • 37
1
vote
0 answers

Turn screen on programmatically without using WAKE_LOCK permission

is there a way to turn on the screen when device is locked. i am listening for proximity sensor events to turn on the screen, but by acquiring wake lock which needs WAKE_LOCK permission. Is there any alternative. Gravity app in playstore does this…
Aun
  • 1,883
  • 1
  • 17
  • 26
1
vote
1 answer

ShadowPowerManager setIsScreenOn(false), but isScreeOn() returns true

I am using Robolectric (version 3) to write test case for my Android project. Here is my simple test scenario: The function under test is : public class MyClass { private Context mContext; public MyClass(Context context) { mContext =…
user842225
  • 5,445
  • 15
  • 69
  • 119
1
vote
2 answers

KeyguardManager fails to unlock kitkat screen

I've noticed very interesting behavior of Android that I cannot explain. I'm using the following code to wake up the phone and disable keyguard: PowerManager.WakeLock mFullWakelock = mPowerManager.newWakeLock( …
NeviQ-OR
  • 305
  • 2
  • 12
0
votes
0 answers

PM: Some devices failed to suspend, or early wake event detected

I am trying to suspend my android device ( on QC platform ) by writing mem to /sys/power/state USB cables etc. is disconnected Display is off, no wake-locks are held by any process. Wifi, BT is OFF. I see below dmesg logs. 938.958977] R0:…
0
votes
0 answers

How to Listening or preventing display shutdown menu in android

I want to prevent opening shutdown menu in android and knows maybe isn't possible. I my solution I want prevent shutdown android device by android menu I have two ideas : preventing opening shutdown menu listening shutdown menu is open and…
0
votes
1 answer

Android updating file in background

I have a link, that allows me to download a calendar file (which can change). I want to re-download this file in the background to see if there is a change in relation to the last and send notification (I have to do some other stuff if an event…
wwwazz
  • 33
  • 6
0
votes
1 answer

Unresolved reference: isIgnoringBatteryOptimization

I'm trying to check if my application is ignoring the battery optimization, I have to force users allow the application in that, I don't wanna to be banned from PlayStore, I saw some references saying that the permission is dangerous. Then, until…
alexandre9865
  • 493
  • 2
  • 9
  • 24
0
votes
1 answer

GPS Service stops after push power button

I'm starting a GPS location service on several devices, the service works correctly in devices with Android Version <= 7 even when the power button is pressed and in the lockscreen status, but I tried in a Nokia 3 with Android 8.0.0 and the service…
0
votes
1 answer

Remap device power button to show a dialog

I want to remap the power button to show a custom system dialog / alert dialog instead of turning the screen off and on. I've looked at the Button Remapper apps but haven't seen any way I can do it. I want to do it without making a custom ROM but…
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

PowerManager does not trigger when Activity is started by the AlarmManager

I'm an artist and I'm working on an installation with a couple Android smartphones. I'm not an expert in Java/Android programming. I'm just learning by doing and stackoverflow is very helpful. I'm using different devices with different Android…
TheArtist
  • 1
  • 3
0
votes
2 answers

How to use PowerManager.goToSleep() in my app that runs on Lineage OS?

CyanogenMod/Lineage OS has a feature to turn of the screen by double tapping the status bar. It just turns off the screen, not locking the device. As far as I know, this is not possible with normal apps. The apps on the Store turn off the device by…
Damn Vegetables
  • 11,484
  • 13
  • 80
  • 135
0
votes
1 answer

Is it because of Doze mode in android, I can never create an accurate alarm clock app using AlarmManager?

I am using AlarmManager, trying to create an Alarm app for android. I noticed that setRepeating was not working when the phone sleeps. So, I tried setExactAndAllowWhileIdle. But, I read this: Unlike other alarms, the system is free to reschedule…
0
votes
0 answers

How to turn off the screen after a period of time?

To unlock the screen in my service, I used disableKeyguard method in KeyguardManager. KeyguardManager.KeyguardLock kl = keyguardManager.newKeyguardLock("MyKeyguardLock"); kl.disableKeyguard(); However, it also removes the auto sleep/turn off my…
user3051460
  • 1,455
  • 22
  • 58