Question

I'm creating an Android application that will register an Observer and listen for events, I will probably use one of the suggestions by Mark in this previous question.

However, my question is, how can I create a "stub" on Android that I can use to fire events at my applications observer? For the purpose of this example, we'll assume that my app is listening for a wifi signal strength, I need to create something that will run on the emulator (or device) that will mock up data to "pretend" it has a strong/weak signal, and to relay that to my app.

Any suggestions?

Was it helpful?

Solution

I am no Android expert but here is my catch.

If you are implementing an observable, I believe you need to create a Service by inheriting from ServiceBase.

Also create a content provider and allow other applications to insert data. The whole notification is built into the framework so if you have a cursor, you will get notifications of change in the data.

So here are the steps:

  • You run the service and register for notifications
  • Application is getting an instance of your service and registers to get back a token
  • They use your content provider to insert event along with the token they got
  • They call the notification
  • You will be notified whenever anything changes.

I know that there are notification services built into the framework but I have never had a chance to look into it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top