Search code examples
androidbackground-serviceandroid-implicit-intent

Android (API 28) - Receiving implicit intents in background


I am wildly confused with the current Android background service possibilities and need some help from an expert :)

The "xDrip" application is broadcasting its information via an (I guess implicit) intent with the action name "com.eveningoutpost.dexdrip.BgEstimate". I want to receive these intents. As it is not allowed to put them into the manifest I registered them dynamically in the onCreate() method of my application class. This is working great as long as the app is running (even when the app is not open on screen). But if I swipe it away in the app overview, it does not receive the intents any more even though I do not unregister the intent.

My question is now: What would be the most suitable way to receive this (implicit) intent reliably all the time? So also when the user swipes the app away in the app overview screen?

Cheers!


Solution

  • This is working great as long as the app is running (even when the app is not open on screen).

    More precisely, this is working great so long as your process is running.

    But if I swipe it away in the app overview, it does not receive the intents any more even though I do not unregister the intent.

    More precisely, you stop receiving the broadcasts once your process stops running. Note that this will happen naturally while you are in the background, even without a manual swipe of your app off of the overview screen.

    What would be the most suitable way to receive this (implicit) intent reliably all the time?

    Technically, it's impossible.

    You will get close if you use a foreground service, to keep your process around longer. However:

    • The user can still swipe the app off the overview screen, and this might still stop your service and terminate your process

    • Even a process with a foreground service might be terminated by Android automatically after a substantial period of time

    • Your app will be consuming system RAM the entire time, which users may or may not appreciate