Hi,

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) {
        super(context);
    }

    @Override
    protected void doWork(Message msg) {
        switch (msg.what) {
            case MSG_EVT_HI:
                Log.i(Constants.TAG, "Messenger received: Hi!!");
                break;
            default:
                super.handleMessage(msg);
        }
    }
}

Second, the Messenger Service:

 public class MyMessengerService extends MessengerService {

 @Override
 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" >
   <intent-filter>             
	<action android:name="es.javocsoft.base.genapp.messenger.ACTION_BIND" />
   </intent-filter>
</service>

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.connect("application.package.service.ACTION"); 
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.

github_icon

As always, library is available on GitHub

javocsoft-toolbox.

Bye.

JavocSoft 2015.

wctime_icon¿Eres amante de la lectura en el baño? ¿Ya te has leído todos los champús, suavizantes y cremas de tu baño?

No te preocupes, ¡Ya esta aquí la aplicación que esta revolucionando miles de baños!

Que eres de leer, tenemos miles de noticias diarias de actualidad para pasártelo en grande.

¿Eres de los que prefieren reírse con unas buenas imágenes? Tendrás las más divertidas de la red!

Sabemos que tu momento en el baño es especial, es por eso que ya tienes aquí WCTime ¡¿A que estás esperando?!

Con WCTime podrás:

• Ver las últimas noticias que revolucionan Internet.
• Compartir todas esas noticias con tus amig@s
• Leer las noticias mas frikis de las redes.
• Puntuar aquellas noticias que mas te gusten.

Ya no hay excusa para que los ratos muertos dejen de serlo :).

Podeis ver los detalles aquí y descargarla y echarle un ojo del store de Android

WCTime
WCTime
Developer: JavocSoft
Price: Free

 

Un saludo,

JavocSoft, 2013