Hello.
I am currently working on an app that is supposed to help me get up in the morning. Normally, when I wake up, I reach for my phone and then proceed to browse on some social media app for way too long.
The app is supposed to work like this:
In the main app, you
select a time (e.g. 4am). Then, you can close the app
This part already works.
At the
selected time, the app is supposed to
"lock" all your apps, until you confirm that you already left your bed.
I found two possible options to achieve this:
- Start a periodic job (e.g. once an hour), that checks, if the current time is greater than the selected time. If this is the case, launch a foreground service that displays an overlay over all applications.
- The android system sends broadcasts on certain events, e.g. (de)-activating airplane mode. If there is a broadcast sent when any app is launched, it would be possible to create a BroadcastReceiver that puts an overlay over all apps.
I have questions for both options:
- Is there a possibility to configure the foreground service in a way that it only displays the overlay over actual apps? Because I only want to block applications, not the entire screen.
- I don't think that there is a broadcast sent on any app launch. If I am wrong, and I hope I am, please tell me.
Thank you in advance for the help
Bennet