How to stop an android device from being charged programmatically?

Android

Android Problem Overview


Is there an Android API for stop charging even though physically the charging is on?

Android Solutions


Solution 1 - Android

Reading previous answers, it looks like there's no way to do this exclusively in software. However, it should be relatively easy to do it with a little hardware help - i.e. by using any Bluetooth- or WiFi-enabled smart electrical switch with open API. The phone could then switch the charger on or off programmatically whenever it feels like it.

Solution 2 - Android

> Is there an Android API for stop charging even though physically the charging is on?

AFAIK no.

Justification:

android.intent.action.BATTERY_CHANGED is a protected intent that can only be sent by the system. Therefore you cannot duplicate or override the functionality.

Solution 3 - Android

You guys are all missing the point - the purpose of limiting charging is to increase battery lifespan by keeping it away from fully charged conditions (and near empty but that's a different issue). If you anticipate needing a full charge then tell it to charge to 100.

If you can't set a charge limit then the battery would rarely be idle and ideally charged when on the charger. It probably requires device level support though.

Solution 4 - Android

https://play.google.com/store/apps/details?id=es.guille.stopcharge uses echo "0" > /sys/class/power_supply/battery/device/charge. It works for me on a nexus 4 (rooted), as long as the device isn't fully charged (in a charging state).

Also relevant: https://android.stackexchange.com/questions/15001/how-can-i-avoid-the-battery-charging-when-connected-via-usb

Solution 5 - Android

Contrary to some answers indicating it's not possible, it is, indeed possible with ROOT. You can find some apps on the Play Store that will allow you to do this (with root permission, of course).

The best app that works on every phone I've tried it on is Battery Charge Limit. You can download it from the Play Store or the XDA discussion thread. The app is under active development so, if you find that your phone isn't supported, just submit an issue on its GitHub page.


NB: I am not the developer of this application.

Solution 6 - Android

This is unfortunately not possible. Android only have read APIs for battery data.

Battery charging control is internal to the Android kernel and battery IC modules. Manufacturers do change it from time to time, like HTC is having small cycles from 95-100% (a bad idea IMO), Samsung does stop charges as soon as it reaches 100%, but I've never seen a device able to stop charging before 100% to reduce battery aging :(.

At best if we're lucky, a sysfs interface might help do that, but it requires root and will differ from device to device.

Solution 7 - Android

Just to add to this. Samsung phones do not stop charging after 100%. As far as I'm aware they "trickle" charge past this point however they recommend you do not charge your phone past 100% for over 1 hour. Battery manufacturers like Anker also state the same so the idea of stopping the charge at 100% would be really useful. The risks of leaving the phone on charge are battery bloat and eventually cell rupture. I wasn't aware of this to start off with an killed my samsung battery within 3 months of owning the phone.

To expand on the original question. I've noticed some kernels allow fast charging. If they are able to alter the charge rate up could we alter the charge rate down (trickle) to meet a desired finish time (when your morning alarm goes off)??

Solution 8 - Android

I have installed a timer on the AC receptacle where I plug my Moto E's charger into. After guestimating how much time the battery needs to charge to about 85%, I set the timer. This is not my idea of a solution, but at least it keeps my phone from being charged to 100%, as I usually err on the short side when setting the timer.

Solution 9 - Android

I dont think there would be such an api. If it does exist it needs to be supported by the device manufacture as its not a pure OS lever feature. The same reason would make it a bad idea to use it as not all devices will support it.

That being said it would be a bad idea to use/implement it , mobile devices are not built to directly run from the power supply and a user will not plug in the cable if he/she did not want to actually charge the device.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondanielView Question on Stackoverflow
Solution 1 - AndroidKibberView Answer on Stackoverflow
Solution 2 - Androidcitizen connView Answer on Stackoverflow
Solution 3 - AndroidBradView Answer on Stackoverflow
Solution 4 - AndroidtheicfireView Answer on Stackoverflow
Solution 5 - AndroidAlex EssilfieView Answer on Stackoverflow
Solution 6 - Android3c71View Answer on Stackoverflow
Solution 7 - Androiduser3498085View Answer on Stackoverflow
Solution 8 - AndroidCP Trail RunnerView Answer on Stackoverflow
Solution 9 - AndroidRavi VyasView Answer on Stackoverflow