Source code of the android app that stops charging at a desired level.
For more info: https://forum.xda-developers.com/android/apps-games/root-battery-charge-limit-t3557002
Since version 0.7, the charging limit can be set using Intents. There are two ways for doing so:
- Using an Intent to Broadcast a message of action "com.slash.batterychargelimit.CHANGE_LIMIT", supplying the percentage by the Intent extra "android.intent.extra.TEXT" (Intent.EXTRA_TEXT). For example in Tasker, the extra could look like android.intent.extra.TEXT:80 to set the limit to 80%. This is technically more clean and therefore recommended!
- Starting Activity com.slash.batterychargelimit.LimitChangeActivity with a ACTION_SEND intent, using MIME type "text/x-battery-limit" and supplying the percentage as String with Intent extra "android.intent.extra.TEXT" (Intent.EXTRA_TEXT). This will cause the receiving Activity to pop up for a short moment. The Intent should be provided with FLAG_ACTIVITY_NO_HISTORY, otherwise the main activity of this app will become the foreground Activity after sending the Intent.