Android - communicating between two devices

后端 未结 8 1133
栀梦
栀梦 2020-11-29 00:59

What is the best way for an Android app installed on two devices to communicate with each other? Can the devices connect directly without using text messaging?

8条回答
  •  清酒与你
    2020-11-29 01:45

    You can connect them via bluetooth using BluetoothSockets. Android developer website has pretty good documentation on this.

    http://developer.android.com/guide/topics/wireless/bluetooth.html

    Or if you'd rather (and have internet on both devices), you can use regular Socket's.

    http://developer.android.com/reference/java/net/ServerSocket.html for server side http://developer.android.com/reference/java/net/Socket.html for client side

    If you have a large amount of data to transfer, internet sockets have a greater data capacity and will be faster. The other advantage is that there is no such thing as "out of range". You can connect the two devices wherever internet is available, whereas with bluetooth they have to be within bluetooth range of each other

提交回复
热议问题