Fennec/NativeUI/Messages

Gecko -> Java

The message object is serialized into JSON, sent to Java, and received at
handleGeckoMessage(). The particular activity in need of events need to register and unregister for the required events. GeckoApp.java's onCreate() and onDestroy() are good examples.

Java -> Gecko

From java we can post message that can be recieved by the nsIObserver. Subject and Data can be anything here: