AsfK
AsfK

Reputation: 3476

What is the difference between triggers and events in Android

I wonder why I cannot receive significant motion sensor data via an event such all other.

As you probably know, we can receive all sensors data via events by Override onSensorChanged method (link) but significant motion sensor is the only one (as I know) we cannot sample with event just with trigger (link). The only point I know is that this sensor must disable himself after event is sending (one-shot).

I assuming if I'll understand the different between events and triggers in Android I'll understand why significant motion sensor works with triggers, therefore my question is "What is the difference between triggers and events in Android"

Thank you!

Upvotes: 2

Views: 416

Answers (1)

nitzanj
nitzanj

Reputation: 1699

There are no inherent events in Android. What you call an 'event' is usually just an interface-variable that you operate on when something happens. In practice it's an event, but it's important to understand that there's no built-in events in the language - just a good use of Java mechanics. There are also no triggers. You could call any event a trigger, there's no real difference. It's just semantics.

to further illustrate this you can Look at the base sensor documentation. You see that they use the term trigger mode to refer to all sensor events, yet they use the word event to refer to the significant motion sensor. Bottom line, everything is the same.

I don't really know why the framework team chose to name some API methods on***Changed and others 'onTrigger'. I can only assume it's meant to be a bit more descriptive - 'Trigger' is more suitable for single time state-change sensor, while onChange is more of a continuous thing.

Upvotes: 3

Related Questions