androidkotlinbackgroundexternalfreeze

Pausing other apps while my floating window app is running


I'm coding an app in kotlin on android studio that appears every fifteen minutes as a floating window on the user's screen. I want whatever the user is currently doing (e.g., watching a YouTube video, TikTok video....) to be frozen (so the user can't interact with it) until the user completes the question that is in my floating window app. My question is how can I make any background apps freeze when my floating window app appears, and then for the app to unfreeze when my app is done/disappears? (E.g., the youtube video pauses when my app appears, the user answers the question on my app, my app disappears and then the youtube video resumes playing).

I'm sorry if this is vague, I just have no idea how to do this and I haven't found anything on doing it. I can add my code if anyone needs it but it would just be my floating window code. Thanks so much in advance. Let me know if anything is unclear. I'm quite new to Kotlin.


Solution

  • My question is how can I make any background apps freeze when my floating window app appears

    There is no requirement for any given app to have the concept of "freezing".

    Even for those that do, there is no requirement that they allow third-party apps, such as your proposed one, to trigger such a "freeze" action.

    And even for the subset of apps that offer "freezing" and allow third-party apps to control it, there is no requirement that there be a standard way of doing that.

    For media apps, you could try to access the MediaSession and trigger a media pause. This would not stop users from resuming the media by some other means, such as a Bluetooth headset's buttons.