You may have some utility class available as singleton (ok, singleton is a dangerous template but this use is justified in android until we get a reasonable and isabile usabel injection) and pass the result.
Advandatges: - do not mess with intentions / sequence - pass data or call some methods or do what you like - all your actions have the same singleton service instance.
Disadvantages: - a singleton pattern is considered dangerous
You can even go further and make your singleton service - you will start using it as an asynchronous task, and then your activity can request results using the selected methods.
Or you can take another step: register your activity as a listener in the asynchronous call service and call the method in this action when you are ready (note: since this will not be a UI thread, you cannot do something with the UI if you use runOnUiThread ()
source share