Android Keep Screen On

Hi, is this still a valid method? I get an unknown error after packaging which disappears after I’ve removed this bit of code from the java file.
Thanks.