How to activate saving battery?

Asked

Viewed 89 times

0

How do I activate battery saving?

I will develop an app that monitors the battery, and that, when it comes to a certain percentage of battery, battery saving is activated automatically.

  • Wouldn’t you like to search the Android documentation? https://developer.android.com/reference/android/os/BatteryManager.html

  • Activating battery saving means disconnecting mobile networks, reducing brightness. That’s it?

  • 1

    @Reginaldorigo, I think he talks about activating the system’s native battery saving feature, which is already automatically enabled when arriving at determianda percentage. In this case, I believe that it only needs its app to be able to handle the value set in the system’s standard battery saving feature.

  • @Reginaldorigo: Yes, today on Android 7.0 (pure), has a feature in his settings that, when the battery reaches 15%, it activates alone battery saving (it does not turn off mobile networks, nor reduces brightness, only turns off animations and reduces processing), I wanted to have "control" on how to turn this feature on and off by programming.

  • @Claydersonferreira, exactly that!

  • @Claydersonferreira I searched the stack in English and google, however, I found nothing to help me concisely.

  • 1

    I don’t think that’s possible. Class Batterymanager only allows monitoring of battery charging levels and status.

  • Check this out. http://stackoverflow.com/questions/28234502/programmatically-enable-disable-battery-saver-mode

  • @Reginaldorigo had already reached this stack as well, however he says it is only possible in "on Rooted Devices".

  • Have you seen if there is an app that does this? I don’t program for mobile, but taking the logic side, I think it’s unviable. The power-saving feature of Android is nothing more than an app that already comes with the system, and being an app, you can’t touch its settings through another app, not without doing some hacking on the device. That would be a tremendous security breach.

  • I believe that this is a cameo below the app, system level even, so I think Voce can not force the economy mode not. In a root (as they said) I believe it is possible since root "releases" access to some previously inaccessible things. Not to mention it would turn into the biggest mess if any app could induce that way

Show 6 more comments

1 answer

1

You cannot activate the economia de bateria programmatically. This is because the android itself does not have a native function that does this and/or does not allow it. You can only do this if the device for rooteado. And even then, it doesn’t have a function that does this, you would have to change a device configuration pattern, you would have to enter a value in its configuration file.

Alternatives

As you want to make an application that will manage the device’s power usage, your only output is to create your own battery saving system.

To do this, you will have to list all the processes of the device or all the running applications, then, you will manage these applications, will close them when necessary, run again when you no longer need to close them and etc.

I’ll leave a link below that will help you do what I said above.

Source: Activitymanager

Browser other questions tagged

You are not signed in. Login or sign up in order to post.