I am working on an well-being app that shuts your phone up for a given period of time (eg. 30min, 1hr, 1.5hr)
In this state user can only see a screen with remaining time on it and cannot
- Access QS tiles
- Access Volume panel
- Navigate out of the Activity
something similar to Oneplus Zen mode
things i have thought of for doing this
Killing the SystemUI process.(by doing so the QS and volume panel would be dealt with most probably, maybe need root for that tho? also SystemUI automatically restarts itself, quite stubborn)
Making app a launcher Dynamically?(technically you can't navigate out of a launcher and on reboot you come back to it)
how can I get around accomplishing this? any ideas?
Making application the default launcher of the phone is more practical solution to what you're trying to achieve. I've done this previously in a Flutter application which was going to be installed on kiosk devices to get orders from customers and it worked perfectly. It's a bit tricky to make it work and there's lots of things to do. Here is a list of things I did back then:
Use
FLAG_SHOW_WHEN_LOCKED
flag to the window to bypass the lock screen.Inside of
onResume
addFLAG_FULLSCREEN
flags to hide the status bar.Make your
MainActivity
launcher by addingLAUNCHER
category to inAndroidManifest.xml
. Also you can add other attributes I used (Search for them if you don't know what are they supposed to do).Listen for window focus changes in your
MainActivity
and bring your application to front if it lost the focus.I was also checking if my application is the default launcher.
And you're gonna need to communicate between Flutter and the platform using
MethodChannel
to enable and disable force mode and get the state of the application.