What is the best method for an object to send a message to another for Android?
Question
For example, say the main Activity has an custom object foo with a method called bar. When foo.bar() is called via the activity, it does a bunch of things on a thread and when it is finished it would somehow alert the main ui thread, the activity, it's parent that it is finished.
I imagine this working the same way an event like a OnClickListener works. The bar() method would trigger an event saying "Hey I'm finished" and that would trigger the listener on the main activity.
Hope that makes sense.
Thanks for your help!
Solution
You basically need the observer pattern. You can read Design Patterns Uncovered: The Observer Pattern
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow