In blackberry we can override keyChar() method and capture the keypress event or we can register onKeyPressListener. i know, onKeyListener is observer pattern.

In android also there is a KeyEvent.callback and onKeyListener

Both are events why we no need to register for keyChar event. what is the difference between both pattern?

2 Answers 2


There can be many listeners for some type of event, but only one callback.

  • In android we can set only one OnClickListener to a view.
    – Vivart
    Jun 17, 2011 at 8:28
  • 2
    It's quite possible that their definition of "listener" doesn't match that of other products. Usualy, you don't have a "setFooBarListener()" method, but an "addFooBarListener()" method.
    – user281377
    Jun 17, 2011 at 8:31
  • 3
    Another distinction could be that callback means a function (or closure or delegate), while listener is an object of a class that implements the corresponding Listener interface.
    – user281377
    Jun 17, 2011 at 8:42
  • Vivart: doesn't matter, my answer isn't that good anyway
    – user281377
    Jun 17, 2011 at 17:17

I suppose that you have an application which use a library:

Listener: Library runs some code on its data, but, the code is implemented on Application.

Callback: Application runs some code on its data, however, the code is implemented on Library.

Because library can't see the application, so there is no way to instead Listener for that case.

Of course Application can see the library, but sometimes library wants to hide it's code, and helps application to make sense with it

Not the answer you're looking for? Browse other questions tagged or ask your own question.