FORUMS
Remove All Ads from XDA

[APP][4.1+] M2D My Second Device

754 posts
Thanks Meter: 270
 
Post Reply Email Thread
Use this one:

http://forum.xda-developers.com/andr...eiver-t2986778
The Following 24 Users Say Thank You to pacosal For This Useful Post: [ View ] Gift pacosal Ad-Free
 
 
17th January 2014, 08:48 AM |#3  
pacosal's Avatar
OP Senior Member
Thanks Meter: 270
 
Donate to Me
More
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.CONNE CTION" />

and in your class use this code:

if (intent.getAction().equals("com.pacosal.m2d.manage r.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
The Following 3 Users Say Thank You to pacosal For This Useful Post: [ View ] Gift pacosal Ad-Free
17th January 2014, 10:17 AM |#4  
Anubhav Agrawal's Avatar
Senior Member
Flag Delhi
Thanks Meter: 1,176
 
More
Quote:
Originally Posted by pacosal

Galaxy Note 3 and show your Xperia U, por example.

spell mistake
concept is good,any chance of connection by internet rather than using Bluetooth,so that I can use it even when I m out?
coz otherwise I will have to be in Bluetooth range to make everything work ..
17th January 2014, 10:20 AM |#5  
pacosal's Avatar
OP Senior Member
Thanks Meter: 270
 
Donate to Me
More
Quote:
Originally Posted by anu.cool

spell mistake
concept is good,any chance of connection by internet rather than using Bluetooth,so that I can use it even when I m out?
coz otherwise I will have to be in Bluetooth range to make everything work ..


Thanks for the mistake

The idea is wear always both devices, because the small one doesn't have SIM

Regards
The Following User Says Thank You to pacosal For This Useful Post: [ View ] Gift pacosal Ad-Free
17th January 2014, 11:46 AM |#6  
Senior Member
Thanks Meter: 108
 
More
Quote:
Originally Posted by pacosal

Thanks for the mistake

The idea is wear always both devices, because the small one doesn't have SIM

Regards

Pacosal my man,

Do both devices need to be running Android?
Could this happen between an iPhone and a Gear?

Thanks!
17th January 2014, 12:31 PM |#7  
pacosal's Avatar
OP Senior Member
Thanks Meter: 270
 
Donate to Me
More
Quote:
Originally Posted by gidi

Pacosal my man,

Do both devices need to be running Android?
Could this happen between an iPhone and a Gear?

Thanks!

Sorry my friend, but only Android
The Following User Says Thank You to pacosal For This Useful Post: [ View ] Gift pacosal Ad-Free
17th January 2014, 12:46 PM |#8  
Anubhav Agrawal's Avatar
Senior Member
Flag Delhi
Thanks Meter: 1,176
 
More
Quote:
Originally Posted by pacosal

Thanks for the mistake

The idea is wear always both devices, because the small one doesn't have SIM

Regards

I don't know anything about coding and all,but it maybe possible to take the app to a whole new level if net connection is possible,like checking on baby when you are out(you can click picture,upload it on cloud and then check it),using your other mobile to use as camera and many more examples ... we can always connect other mobile through wifi!
I am half dead atm(sleepy I mean) so can't really think much,but do give it a thought...
18th January 2014, 06:49 PM |#9  
pacosal's Avatar
OP Senior Member
Thanks Meter: 270
 
Donate to Me
More
version 1.1.0
- New options for developers for not to store messages not sent if there is no connection in that moment.

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 Following User Says Thank You to pacosal For This Useful Post: [ View ] Gift pacosal Ad-Free
24th January 2014, 10:12 AM |#10  
pacosal's Avatar
OP Senior Member
Thanks Meter: 270
 
Donate to Me
More
Version 1.2.0 out!

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.

**
The Following User Says Thank You to pacosal For This Useful Post: [ View ] Gift pacosal Ad-Free
25th January 2014, 09:38 AM |#11  
pacosal's Avatar
OP Senior Member
Thanks Meter: 270
 
Donate to Me
More
Version 1.2.1 out!

- Bug Fixed!
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes