I am trying to create an app that will keep my device wake until I tell it to turn off via code. I can use the follow code in a application...
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
That will work until I tap on the home soft button and then the flags will clear. So, I thought of putting that code in a foreground notification service and broadcast receiver for my action buttons. I can't getWindow in a service or broadcast receiver classes unfortunately. Is there an easy way to get around this?
My goal is to setFlags to keep the screen on from the Activity, and then the service takes over from there so I can close the app, and the keep on screen stays on until the service is turned off.