[APP][4.1+] M2D My Second Device

Search This thread

pacosal

Senior Member
Oct 6, 2010
801
299
www.pacosal.com
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
 
Last edited:

Anubhav Agrawal

Senior Member
Nov 26, 2012
822
1,264
Delhi
Thanks for the mistake :eek:

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...
 

pacosal

Senior Member
Oct 6, 2010
801
299
www.pacosal.com
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) ;
 
  • Like
Reactions: genius.lizard2

pacosal

Senior Member
Oct 6, 2010
801
299
www.pacosal.com
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.

**
 
  • Like
Reactions: jdstrydom

SSThing

Senior Member
Jan 16, 2012
226
42
I have asked this question several times on XDA and had no luck, but this seems to be going the right way.
My main phone has to be connected to an external antenna when I am at home because the signal is so poor, I have a couple of spare phones that I want to be able to connect via Bluetooth to my main one, so that I can leave them in other rooms, and when a call comes in I want to be able to use either one as a `remote phone`, can you foresee this being possible? I would have thought, that if a GalaxyGear can remotely make/receive calls then surely a second Android phone can be utilised the same way?
Thanks
 

pacosal

Senior Member
Oct 6, 2010
801
299
www.pacosal.com
I have asked this question several times on XDA and had no luck, but this seems to be going the right way.
My main phone has to be connected to an external antenna when I am at home because the signal is so poor, I have a couple of spare phones that I want to be able to connect via Bluetooth to my main one, so that I can leave them in other rooms, and when a call comes in I want to be able to use either one as a `remote phone`, can you foresee this being possible? I would have thought, that if a GalaxyGear can remotely make/receive calls then surely a second Android phone can be utilised the same way?
Thanks

Hi,

this would be perfect, but for calls it's not possible because Android framework don't have the required bluetooth profiles for this. I think Galaxy Gear has implemented this feature.

What we can get with this App and modules is to warn you when you receive a call in your main device and take it or not. To take it you will need a bluetooth hands free gadget.


Thanks
 

pacosal

Senior Member
Oct 6, 2010
801
299
www.pacosal.com
Working in several Apps in order to get these:

Could be used in both devices (main and auxiliary). Like a remote.

- Be able to camera preview and take pictures as well.
- Be able to record sounds
- Be able to control media player

Working in first option right now!
 

frounzn

Member
Dec 31, 2007
37
8
Samsung Galaxy S6 Edge
Very cool project. Do you plan to add a windows desktop client/receiver.
I've seen something like your app which sends notifications through internet, but Bluetooth would be very cool.
 

hasan4791

Senior Member
Nov 2, 2011
1,801
610
Gurgaon
Also if we getting a call in second device, can it be transferred to primary device thro BT which is quite handy and usefull...!!...coz I've 2 sim card and 2 smartphones....!!
 

SchizoDuckie

Member
Jun 8, 2008
19
11
This is super awesome :D

Any plans to allow multicast?
So not just one slave, but many, that could daisy chain even?

Crazy idea in my head: Hook up a multitude of different devices, and have them all snap a picture at the same time
 

Top Liked Posts

  • There are no posts matching your filters.
  • 3
    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
    1
    spell mistake :p
    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 :eek:

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

    Regards
    1
    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