Search code examples
androidandroid-ionion-koush

Using Ion with an Application Context


I'm interested in using Ion/AndroidAsync for the "backend" of an Android app. I don't want to make long running calls tied to an Android component, so I have a background layer that stays alive as long as the Application is alive. This background layer has an API that allows the UI to make async calls to perform different tasks, and returns a Future to the UI (also allows for a callback that gets executed on the main thread) so that it can be passed between components if need be.

I like Ion's API, but don't want to call it from an Activity; rather, I'd like to use it in my background layer, since a "task" may also need to do other long running operations in conjunction with a network call. That being said, will I run into any issues if I pass an application Context to Ion.with()?


Solution

  • It will work fine with an Application Context. It will never cancel any requests, as the Application context never dies. But that is what you want.