I may have missed this, is there any way to turn off device with code. I want to try a sleep timer in a media player that turns off the device after a selected time.
If you mean a complete power down cycle, that is a protected intent that can only be sent by the system. Others correct me if I'm wrong, but I'm pretty sure it can only be handled by the physical button.