I'm working on writing a test to be added to an automated test script, and I want to be able to guarantee that the phone's screen is on as part of my initialization process. I have no real preference as to how to accomplish this, so I'm fine with either ADB or Java, or whatever method might be applicable.
The answers give solutions using both code in the onCreate method or adb.