How can I charge an Android phone while it's controlling my 3D printer? I am writing a G-code sender for Android, but I have hit a snag.
How can I prevent the phone from discharging while it sending G-code to the printer?

I have several Android phones and tablets and they have a micro USB OTG connector, which I can connect to my 3D printer using an adapter.
But it looks like OTG has this limitation - it can either accept power when in Device mode, or it can provide power in Host mode.  So, while in Host mode the phone can't be charged, so I can't do long prints, which seems like an unreasonable limitation.  

Any ideas on how to solve this?
See elsewhere on StackExchange:


Electronics:


Can an Android tablet serve as USB Host and be charged simultaneously through a single port?

Android Enthusiasts


Using an OTG cable while charging
USB charging in host mode [duplicate]



You certainly can charge whilst in host mode, but some re-wiring will be required.

From the SE.Electronics link


  Apparently it is possible to charge the Host-Device! -->
  http://en.wikipedia.org/wiki/USB_On-The-Go
  
  Under "OTG Micro Plugs" it says that a USB OTG cable with a 36.5 kΩ
  resistor between Pin 4 (I suppose its pin 4) and Pin 5 allows you to
  connect a B-Device (Slave) and (!) a Charger to the Smartphone/Tablet.
  The Phone and the B-Device can be supplied by the external power
  source.
  
  USB-Power Specifications:
  http://www.usb.org/developers/devclass_docs/batt_charging_1_1.zip


and 


  I just sifted through the docs because I didn't trust Wikipedia's implicit data on which of the three resistances I should use. Here you can find the official Battery Charging v1.2 Spec and Adopters Agreement: usb.org/developers/docs/devclass_docs In this case you want 124kΩ, because you want the OTG device (=tablet) to be the A device (=host). 


Here are the schematics: