I am trying to build an app which will prevent the phone screen from going off(even if the app is minimized to background)
I know that this feature is definitely possible as there are many apps in Play Store that does the same.
https://play.google.com/store/apps/details?id=com.eonsoft.ScreenON
This particular app prevents phone going to timeout for an infinite period of time. They ask for Draw over Other Apps Permission. But I am not able to figure out how it can help preventing phone from screen timeout. Can any of you experts guide me how I can achieve this?
Things I have already Tried:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
But the above code prevents phone from screen timeout only if my app is opened. I want this to work even if my is minimized.
I have tried the solutions given here: Android disable screen timeout while app is running
But the above solutions work only if my app is running. Let me explain with a use case scenario. I want the screen from going to timeout when they are reading a document using a PDF Viewer of their choice(in this case my app may not be active as they have minimized it )