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
59
votes
4 answers

Check if battery optimization is enabled or not for an app

Android 6 and 7 have some power optimizations (doze mode) which restrict app networking when device is not used. User may disable optimization mode for any app in Battery settings: Is it possible to check if optimization is enabled for my app or…
Nik
  • 7,114
  • 8
  • 51
  • 75
29
votes
2 answers

WakefulBroadcastReceiver is deprecated

For creating a receiver I'm extended WakefulBroadcastReceiver in my old project. But now it's deprecated. Instead of WakefulBroadcastReceiver which Receiver I should use now and how to convert below code with new method? Here is my code: public…
Yeahia2508
  • 7,526
  • 14
  • 42
  • 71
16
votes
7 answers

isPowerSaveMode() always returns false for Huawei devices

I am currently implement a feature where the users are requested to ignore battery optimisation for the application. The reason for doing so, is that the main functionality of the application is unfortunately drastically affected by power save…
Demitrian
  • 3,200
  • 1
  • 24
  • 41
14
votes
3 answers

What should I replace SCREEN_DIM_WAKE_LOCK with?

I am currently utilizing the below referenced code for a wake lock on an alarm notification activity. However, SCREEN_DIM_LOCK has been depreciated. So, what should I be replacing it with? //Instance of wake lock for AlarmActivity PowerManager pm =…
user3391426
  • 433
  • 1
  • 5
  • 17
11
votes
3 answers

Reboot the phone on a button click

I am making an Android app that needs to have the phone reboot or turn off when a button is clicked. Is this possible? Or will the phone require root access?
IntelSoftApps
  • 1,161
  • 3
  • 14
  • 18
9
votes
3 answers

Turn ON Screen programmatically on Android

I need to programmatically turn the screen on when the user turns off with power button, and yes I always have the correct flags in the Activity to keep screen on, but it does not avoid user pressing power button. So far I've found a solution but it…
sherpya
  • 4,890
  • 2
  • 34
  • 50
8
votes
4 answers

What does "PowerManger.FULL_WAKE_LOCK is deprecated" mean?

I have this code: wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "MyWakeLock"); And the FULL_WAKE_LOCK is crossed out and it's saying…
silvia_aut
  • 1,481
  • 6
  • 19
  • 33
7
votes
2 answers

Python script to charge and discharge laptop battery

A friend of mine recently inherited an old laptop and has freshly installed windows 7, and wants to increase the battery life. Initially the battery lasted around 20mins, but by manually allowing the battery to fully discharge before recharging, a…
Cornspierre
  • 322
  • 1
  • 5
  • 14
7
votes
1 answer

How make mobile go sleeping programmatically

I need to do an application that turn off the mobile screen and go to sleep programmatically. For example if screen is on for more than 5 minutes without user_present, I should turn it off. I tried to use PowerManager (goToSleep() function should…
Alex
  • 239
  • 5
  • 12
6
votes
1 answer

Wake up android phone on an interrupt, on a GPIO

On Android development board, I am trying to wake up the AP based on an interrupt received on a GPIO, can anybody help me with this? My understanding on this is: We need to create an input device and update an event to this device based on the…
kumar
  • 73
  • 6
6
votes
1 answer

Android ACTION_SHUTDOWN Broadcast not working

Code - public class ShutdownReceiver extends BroadcastReceiver { private static final String TAG = "ShutdownReceiver"; @Override public void onReceive(final Context context, final Intent intent) { Logger.i(TAG, "Shutting…
Scorpion
  • 6,831
  • 16
  • 75
  • 123
5
votes
1 answer

Android wake lock force close

Hello I am trying to implement a wake lock for an application. PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag"); It seems to force close when…
Tom
  • 7,316
  • 9
  • 35
  • 35
5
votes
1 answer

What is the latest auto-start activity intent for Huawei's system settings?

Previously, an intent with one of the following components lead me to Huawei's system settings to change the auto-start behavior of an app. ComponentName( "com.huawei.systemmanager", …
5
votes
3 answers

Android isScreenOn Nullpointerexception

i used this code to keep the screen on on Android 4.4.2. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
Fabian
  • 167
  • 1
  • 9
5
votes
2 answers

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

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…
Pich
  • 55
  • 1
  • 4
1
2 3 4 5 6 7 8