I am working on an android project where I use a phone to power an external device. Through a USB-OTG connection, I can power the external device.
I want to know if I can write a program on android studio where I can press a button in the app to toggle the power to this external device (turn it on and off).
I've seen it done before on an older Samsung Galaxy 3 phone (on a much older version of android) by updating data in a file; specifically this file:
/sys/devices/virtual/host_notify/usb_otg/mode
But I'm trying to write the software so it is more generic and can work on any new android device.
Is there a way to do what I need?