Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android power save mode listener?

Tags:

android

How can an Android listener be created to perform a task just before entering power save mode? Also: what are some of the low power options that can be controlled by this task?

like image 440
jacknad Avatar asked Nov 09 '10 22:11

jacknad


People also ask

Does Powersave mode drain battery faster?

In our tests, both iPhones and Android smartphones used significantly less battery power with battery-saver mode enabled—as much as 54 percent, depending on the phone we used.

Does Powersave mode improve performance?

Power saving mode in phones usually do not change the CPU settings(Manipulating CPU configurations is usually not possible without first rooting the phone). So they do not affect the performance noticeably.

How do I bypass power save mode?

Click the battery icon on the right side of the Taskbar. Select Battery settings. Scroll down to the Battery saver section, and disable the check box next to Turn battery saver on automatically if my battery falls below.

What is Android Powersave mode?

When turned on, 'Power saving mode' reduces your device's performance and limits vibration, location services and most background data. From a Home screen, swipe up or down from the center of the display to access the apps screen.


1 Answers

The answer above(for API 21 and above) is not exactly right. You should register a receiver in your activity or service like this:

BroadcastReceiver powerSaverChangeReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        checkPowerSaverMode();
    }
 };

IntentFilter filter = new IntentFilter();
filter.addAction("android.os.action.POWER_SAVE_MODE_CHANGED");
registerReceiver(powerSaverChangeReceiver, filter);

The reason for this is that receivers in manifest are not triggered by this broadcast.

ACTION_POWER_SAVE_MODE_CHANGED

Intent that is broadcast when the state of isPowerSaveMode() changes. This broadcast is only sent to registered receivers.

I have tested this and it works.

like image 84
user6697486 Avatar answered Nov 01 '22 18:11

user6697486