JavocSoft Android Toolbox – Inter-Application Messaging – Update (10-07-2015)

10 Jul


In this update I added some assistance classes related with inter-application messaging in Android to JavocSoft Android Toolbox.JavocSoft Android Toolbox Library

Sometimes an application needs to accept messages from other applications, in those cases, a Messenger service must be implemented. See Messenger for more information about messaging. So, to make easier having a messenger service in an application, i have added a base MessengerService.java class to the library. Click here to access to the Messenger Service Wiki.


Here can be seen full example of how to have a valid Messenger Service in your application:

First, create the message incoming handler:

public class MyMessengerIncomingHandler extends MessengerIncomingHandler {

    //Messenger WHAT possible values
    public static final int MSG_EVT_HI = 1000;

    public MyMessengerIncomingHandler(Context context) {

    protected void doWork(Message msg) {
        switch (msg.what) {
            case MSG_EVT_HI:
                Log.i(Constants.TAG, "Messenger received: Hi!!");

Second, the Messenger Service:

 public class MyMessengerService extends MessengerService {

 protected MessengerIncomingHandler getMessageIncomingHandler() {
    return new MyMessengerIncomingHandler(context);


And finally, in our AndroidManifest.xml:

<!-- Application messenger -->
<service android:name="es.javocsoft.base.genapp.service.MyMessengerService" 
	 android:enabled="true" android:exported="true" >
	<action android:name="es.javocsoft.base.genapp.messenger.ACTION_BIND" />

Because we could need also to connect and send messages to other applications messenger services, I also added a class Mezzenger.java. Click here to access to the Messenger Wiki.


Mezzenger messenger = new Mezzenger("Inner", getApplicationContext()); 
messenger.sendMessage(MSG_EVT_HI, 0, 0, null);


Do not forget to check the blog to get more updates!

More info and HowTo at https://github.com/javocsoft/javocsoft-toolbox/wiki.


As always, library is available on GitHub



JavocSoft 2015.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.