Search code examples
androidobserver-pattern

How can I "poke" an android application that adheres to the Observer pattern?


I've got a small android application that implements the Observer pattern.

I want my "subject" (or the thing being observed) to change its state, such as changing its String from hello to hello world.

How can I do this via the emulator?

I need my (observing) android application to still run in the foreground so it can display whatever is being observed, but I need to find some way to alter the state of the observed object, is it possible to do this via the command line? How else can I "poke" the observed object to change its state.

One dirty-hack method I can think of is to set the observed object up in a loop, so every 10 seconds it changes its state, but that is not good as then I won't have control over it.


Solution

  • Correct answer: write a test case, and have the test case "poke" the observed object.

    Not-quite-as-correct answer: add stuff to your activity to "poke" the observed object.