[Android Apps and Games] pacosal:
Developer Post:

Want to use M2D Manager for your own modules? Get rid of bluetooth connections and leave that for M2D Manager. Focus on your App.

In order to send a message between devices, the message goes first to M2D Manager with an Intent this way:

Intent i = new Intent("com.pacosal.m2d.manager.action.MSG");

i.setPackage("com.pacosal.m2d.manager");

i.putExtra("action", "Your receiver package and filter");

i.putExtra("data", "message");

sendBroadcast(i);

***********************************************************************************

** version 1.3.0

***********************************************************************************

Added feature to ask m2d Manager for connection state

Register for this filter in your ExternReceiver:

<action android:name="com.pacosal.m2d.manager.action.CONNECTION" />

and in your class use this code:

if (intent.getAction().equals("com.pacosal.m2d.manager.action.CONNECTION")) {

connectionState = intent.getBooleanExtra("connected", false);

return;

}

If you need to know the connection state, you can ask m2d manager with this code:

Intent i = new Intent("com.pacosal.m2d.manager.action.CONNECTION_STATE");

i.setPackage("com.pacosal.m2d.manager");

this.sendBroadcast(i);

***********************************************************************************

** version 1.2.0

***********************************************************************************

Added feature to send and receive binary files. Don't send binary files greater than 500.000 bytes.

To send:

intent.putExtra("binary",byte[]) ;

To receive:

byte[] dataBinary = intent.getByteArrayExtra("binary");

If you need sending greater files, send them with several messages and concatenate them.

***********************************************************************************

** version 1.1.0

***********************************************************************************

By default, M2D Manager stores messages if there is no connection between devices in real time, if for your App the message is only valid in real time, set the following flag. For instance for an instant action.

intent.putExtra("flagNoStore",true) ;

***********************************************************************************

The action parameter include the filter broadcast that the receiver App must implement.

The data parameter is a String message to send to your App. Could be any String text, including json

In order to receive the message in the other App (Could be the same App) M2D Manager send an Intent with the action text you sent before that you have to register in your manifest:

AndroidManifest

<receiver android:name="your_package.ExternReceiver" >

<intent-filter>

<action android:name="Your receiver package and filter" />

</intent-filter>

</receiver>

Class

public class ExternReceiver extends BroadcastReceiver {

public void onReceive(Context context, Intent intent) {

// Do actions...

String data = intent.getStringExtra("data");

Log.D(TAG, data);

}

}

Remember including in Google Play description the sentence M2D My Second Device Module at the end in order that users can find your App from M2D Manager.

Thanks