Let's assume I have an app that has the idle timer disabled and will continue to run when the application state is not active (in background while using other apps or in lock screen, think audio playback) but it should stop when the device enters sleep mode (i.e. the screen goes black).
Is there a way to detect that event and stop the app's processes?
Since it would be an app utilising the audio playback required background mode it would continue otherwise.