I'm presently using the Blackr android app to shut off the display, while leaving my serial OTG app running (on screen). Works fine, but, too many moving parts. Blackr provides a Tap-ring to sleep-screen, and double tap screen to open. Great, but I'd like to build-in this feature.
A Google search returned this: de.bodymindpower.IdleMode.aix but I'm reading mixed unrelated questions about detecting screen on/off.
From Google AI:
The
de.bodymindpower.IdleMode.aixextension is designed for MIT App Inventor to manage device sleep, allowing apps to stay active even when the screen is off. It is used to detect when a phone is in idle/sleep mode and enables background tasks to run, preventing the app from closing.
I can't find the author's full list of capabilities.
Any other suggestions?
It would be best for the app to be in foreground, rather than in background(not immediately visible when screen wakes).