简体   繁体   中英

How to Send a toast message between two devices on android

I'm trying to make a prototype android application similar to Uber ... so I made two applications "User" and "Driver" .

and my question is :

is it possible for the User application to send a toast message to driver application and vice versa ? , even if these two applications are located in two different devices ?!

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

Check this example Android Socket Example

Connecting to Bluetooth enabled device

Yes it is, you may use Androids Nearby features to implement this for close proximity messaging. You will have to roll your own Web Service/Messaging Service, maybe based on Google Cloud Messaging to provide a long range service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM