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
0
votes
1 answer

How can I programmatically turn off screen in android?

I want to turn off the screen when the user clicks a button. I am trying to do it with PowerManager class but I don't obtain good results. What is the best way to turn off the screen in android?. I am using the code below: PowerManager pm =…
moisesvs
  • 51
  • 1
  • 1
  • 3
0
votes
3 answers

How to shut down android device programatically using Intent or PowerManager API?

I am trying to shutdown my custom android device programatically. I am using the below code to do the same, but it is restarting again.I want the device to be completely shut down. Intent intent = new…
user2879697
  • 69
  • 1
  • 10
0
votes
1 answer

Android unable to start sensor service class from fragment

I have a main activity with a nav drawer that brings up different pages as fragments. In one of the fragments there is a button, that when clicked will start a sensor service and store sensor info to a database in the background even when the screen…
0
votes
0 answers

Android device boot into the operating system when USB power adapter is plugged in

I would like to have my Android device boot into the operating system when I plug in the USB power adapter. Solutions are available on SO that involve editing "/system/bin/lpm" as shown below. #!/system/bin/sh /system/bin/reboot Variations on the…
0
votes
1 answer

How to turn on screen again after user lock screen while activity is in foreground

Scenario: I have an activity that is running in foreground.. After a while, screen will auto lock. Later, I receive a new Intent that requires the screen to be shown again regardless of lock screen.. How should I turn on the screen while this…
xialin
  • 7,686
  • 9
  • 35
  • 66
0
votes
2 answers

How to use powerHint in an android application?

I'm working on power optimization. Is it possible to call powerHint in PowerManagerService from an application? How can I call it? Is there any way to call the method via below pm? PowerManager pm = (PowerManager)…
0
votes
1 answer

Receiver capture power button presses

Im creating a receiver that captures power button preses, and for now its working but its not behaving like I want to. In it its defined to do certain action if the user presses 5 times in less than 5 seconds, but for now its not that responsive and…
0
votes
1 answer

How to invoke an android device from sleep?

In my application I have to enable the device 5 seconds after falling to sleepmode. I have tried different methods like PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); WakeLock wakeLock =…
svs
  • 377
  • 9
  • 21
-1
votes
1 answer

Android power button override and disable while application runing

hi i need to keep the device screen on mood, while application running. disable the power button functionality to off the screen. I have tried following codes getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); and wake locks…
-1
votes
1 answer

java.lang.NoSuchMethodError in PowerManager

I got the below error log and not sure how this could be fixed Caused by: java.lang.NoSuchMethodError: android.os.PowerManager.isInteractive at…
Sweety Bertilla
  • 972
  • 10
  • 35
1 2 3 4
5