Why does your battery’s percentage decrease even though it’s connected to the charger?
You plugged in your phone and it should be charging like as expected, but it doesn’t. There are many phone utility applications that will auto close running apps in the background which consume your battery and apps meant to protect your battery. Overcharging is probably the biggest element in the life of a battery, and the single biggest contributor to the likelihood that the Li-ion battery could explode.
Overcharging phone battery will decrease its life faster than anything else. Current lithium batteries and lithium-ion batteries biggest issues are thermal runaway passivity that resulted earlier on, before fail-safe mechanisms were built into batteries and battery packs, before more recent changes to the chemistry of the batteries were introduced.
Although allowing the battery to completely deplete its charge is not desirable, over-charging is more detrimental to the battery and phone, to the life of the battery and to the risk of explosion. Most electronic devices have integrated circuits which will shut the phone down before it is completely 100% drained. Some will cut off the incoming current when fully charged.
Just by charging a Li-ion battery, the phone will heat up because charging the battery heats up the battery. This temperature increase, combined with the CPU that is already running (possibly running useless apps and processes in the background) is one major reason why the battery does not steadily increase while being charged, while it is powered on or running. Of course, the charge rises steadily while charging when it’s powered off, but when it’s on, the CPU is hot, and the battery makes it hotter.
There is more of a load on the CPU and RAM than there would be if it were cooler. Curious about this question myself, I tested the phone charging under different conditions. When the phone is cooled by air conditioning, the rate of charge build-up differs dramatically if the phone is uncooled and heating up due to heat inherent from charging. One can test this for themselves.
It may also involve a USB or charging cable that has broken strands within the cable, usually near the connector from all the bending over time.
It may be possible to feel the heat within the cable. One useful tip is to avoid using resource-maximizing apps while charging but to simply charge with the phone powered off. It will charge faster and cooler, instead of being long and drawn-out while exposing the phone to prolonged and excessive temperatures. Just remember to turn it back on till you remember to do so (especially if your phone is your alarm clock).
If it is not possible, to charge with power off, minimize (remove) the apps that were installed but are seldom or never used; that may help significantly. Sometimes a hard drop of the phone may cause damage that leads to hot phone charging for a various reason, even after swapping out the cable and a suspect battery (if still removable).