S
S
Sam2016-10-31 09:21:49
Java
Sam, 2016-10-31 09:21:49

How to implement an interrupt in Android? Which architectural pattern is right for you?

Please point to an appropriate architectural pattern that would do something like interrupt an application on service events.
Task.

  1. Let's say I have sensors, and in the service I update them endlessly upon request to the device.
  2. I need to be able to request actual sensor readings from the service at any time.
  3. If I don't even call the service, but it received data outside the safe range, the program should be interrupted anywhere and a full-screen error message and how to fix it are shown.

It seems to me that I need my Service to be the "publisher" and Activity the "subscribers", which are assigned a Sensor Event Listener. Or not? How to make it more beautiful?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2016-10-31
@sammolove

Yes, through the service - a good solution. use LocalBroadcastManager - it's more efficient.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question