Don't charge the battery but use connected power to run the phone Answers to this question Is power consumed from battery to run the phone when charging? explain how charging while phone is in use does both - charging the battery and powering the on going activities.

My question is different — Can I stop charging the battery but use the connected power for ongoing activities?

Why do I want to do this? 


I want to charge the battery within ideal limits (see Ideal charging / discharging percentage for maximum battery life?) 


and 


at the same time use the charging power to keep running the phone without any heat stress on battery, thus extending battery life. 
Also the battery is not drained, enabling me to use the phone for longer time without charging


Edit : I am not looking for dedicated cables or hardware that can possibly do this
Yes, it's possible if your device is rooted running Advanced Charging Controller-Acc Magisk module
and device kernel supports (see currently known list at the end of answer) 


Battery Idle Mode: To activate this feature at a user defined battery level. 


And/Or 


Custom Charging Voltage Limits: Activates this feature at a user defined voltage level. This method is superior to first method since granular voltage control is possible  Keep in mind that battery charge level is not an accurate indication of voltage. Kernels that support this, include support for first mode too.


First step is to configure charging to be stopped at a safe level, in my case, 75%, using the Acc module

Next step is to use the charging power to run the phone only

How does it work?

In either methods (battery idle mode or Voltage based) , the charger is fooled into "believing" temperature conditions aren't good for charging (either the reported battery temperature is too high or too low, so battery charging is discontinued as a safety precaution). 

That means the device is drawing power from the external power supply alone - which is exactly what we wanted! And the battery doesn't get drained because it is not being used (of course over a long period of time it would drop a percentage point. As an example I used the device to surf for 4 hours, mostly YouTube videos and lost  just 1% of battery) 

On my OnePlus 7, battery idle mode is supported by Kirisakura kernel. Interestingly, beta versions of stock ROM have this feature in stock kernel but one doesn't know if it makes it to next stable version (Edit : Stock kernel on 10.3.2 supports idle battery mode as verified by me) 

When this feature is running, a low USB  equivalent power is fed to the phone and conventional charging indicators show charging with zero power. Note that the second screenshot (Ampere app) shows "not charging" and no word about discharging, so the battery is at status quo. Normally, such apps show a binary status, either charging or discharging. Here, you see the difference 





This screenshot below is from ACCA (Acc App, optional companion app of Acc magisk module ) which offers all the command line options (believe me, a ton of them) in a user friendly GUI. It shows battery charging idle mode at 75%





Support Battery Idle Mode


Asus Zenfone Max Pro M1
Essential Phone
Lenovo K5 Pro L38041 (kunlun)
Motorola Moto G4 Play
OnePlus 7/Pro 
Xiaomi Redmi 3 (ido)
Xiami Redmi Note 8


Support Custom Max Charging Voltage


Essential Phone
Lenovo K5 Pro L38041 (kunlun)
Xiami Redmi Note 8
...