0

What is the difference between an event that has been "consumed" vs an event that has been "handled"?

Appreciate the help :)

[Edit] For example:

onTouchEvent(MotionEvent event) returns true if the event was handled - false otherwise

onTouch() returns true if the listener has consumed the event - false otherwise

Zac
  • 53
  • 1
  • 7
  • 2
    In my understanding “consuming” the event means indicating that no other handler should handle the event. “Handle” does not necessarily imply that. I don’t know Android well enough to tell whether this is also the intended meaning there, though. – Ole V.V. Jun 17 '19 at 06:10
  • Possible duplicate of [What is meaning of boolean value returned from an event-handling method in Android](https://stackoverflow.com/questions/3756383/what-is-meaning-of-boolean-value-returned-from-an-event-handling-method-in-andro) – ADM Jun 17 '19 at 06:20
  • @ADM, i have looked through that. I don't believe that question/answer is quite aligned to what I am asking. It doesn't seem to explain the differences between the 2 actions; "handle" and "consume". – Zac Jun 17 '19 at 06:30

2 Answers2

1

Consuming an event means subscribing to it so that a user's application is informed when the event occurs. This could include subscribing to an event via an API or to receive notifications from an event producer.

Handling an event means taking action when it occurs. This could include creating an event handling function that will execute code once the event is triggered. Examples include responding to a user input, such as clicking a button, or running a code snippet in response to an asynchronous event, such as a message being delivered.

alelom
  • 2,130
  • 3
  • 26
  • 38
-1

Event handling: When an event happens and we have registered an event listener for the event, the event listener calls the Event Handlers, which is the method that actually handles the event.

Zac
  • 53
  • 1
  • 7