How to send and receive Data between Devices with Flutter/Dart? - android

I would make an app to play with playing cards.
To make this app:
I must send and receive data between devices.
I would make it with mobile hotspot, so that all devices are in the same wireless network, also without connection to the internet.
How can I do this with Flutter/Dart? Any ideas? Or better with bluetooth? Or with internet connection?

I think that a way of doing this is with mobile hotspot, by using the UDP protocol of communication between devices through a local network.
There is a class in a flutter that does what you are looking for, just search for send and receive via UDP in flutter and you will find a lot of ideas, projects, classes, and packages.

Is P2P communication between devices a hard requirement for you? Otherwise, Firebase real-time database will be an easy solution for you. This will require internet connection.

Related

App that will communicate between devices connected on the same local network Wi-Fi

So there's a requirement for an app that will communicate between devices if and only if its connected to the same local network.
E.G: Device A and Device B are connected to Wi-Fi network Z. The app will allow both the Devices to communicate between eachother (send messages/videos)
I've been researching the past couple of days but unable to get clarity with what I've found so far. (I'm confused between NSDManager, WifiP2pManager, etc. as to which one suits my requirement).
I just need confirmation between which concept/methodology to follow. Please help.
From my personal experience, WiFiP2PManager should do what you want. I have used it to connect two devices over the same WiFi network. It also allows your device to view all the other devices on the network and enables you to connect to them. Once you have connected to the device, you can then send messages across the WiFi network. This documentation does a good job of explaining how to use WiFi P2P and how to get started.
It also explains how to view devices on the network, how to connect with them, and how to transfer data. This should suit the requirements that you requested.
You can use NSD, but according to the documentation that is mainly used for giving your app access to services provided from other devices on the local network. It would allow your app to do file sharing with the other device by requesting a service.
After searching it up, I have concluded that WiFi Direct is the same as WiFi P2P. They both use the WiFiP2PManager.Here is a link for information about it.
You can use Network Service Discovery to find and connect to instances of your app. You can then open a socket connection to facilitate communication.
I created and example app on Android and on iOS that does this which I link to and explain in great detail here: http://brendaninnis.ca/connect-nearby-devices-part-2.html

Transfer Data over wifi in android between server and clients

How can I do these steps in android (Eclipse)? In a simple example. I am beginner.
For transfer data over wi-fi.
Server device opens a socket and listens on it.
Server device broadcasts the local IP and Port it's listening on.
Client devices receive broadcast and initiate a connection.
Transfer data between server and each client or clients and server.
This is very broad and would require a lot of code to show, and therefore I recommend viewing
http://developer.android.com/guide/topics/connectivity/wifip2p.html
WifiP2P is very cool, but can be tricky to setup. If you want to start playing around with wireless communication you may want to look at the BluetoothChat Example.
Bluetooth and specifically Bluetooth Low Energy are emerging as the standard communication protocol for Internet of Things. If you want to start digging into what you can do the example should work right off the bat with the latest version of Android Studio.

Is it possible to create and join a local network without losing internet connection

I am writing an Android server app that streams mjepg video using http local connection to a client (Google Glass) under the same network environment.The Glass does not support 802.1X EAP so I choose to host a portable HotSpot (teathering) on the server allowing Glass to join. Doing so gives Glass access to the local ip of the server. At this point neither the server nor Glass have internet connection (since they are connected locally with HotSpot and neither has 3G).
My question is if there is a better way to achieve peer to peer video streaming without having to give up the ability to connect to the internet?
Sorry in advance if what I have said above seems ambiguous. I have very little prior knowledge in networking.
==03-07-14 ==
Thanks #greenapps I have updated the question. I hope this is clearer :)
No, the Android device most probably only contains a single wifi client, and it will be unable to perform both as a teathering hotspot and also being connected to another WiFi infrastructure.
The best way to do this, is to have both you clients connect to the WiFi infrastructure instead. But as you hinted, the infrastructure network uses 802.1X EAP, and Google Glass does not support it.
So you are only left with the solution of using another WiFi infrastructure than the one you are trying to use.

How to connect two Android devices over GPRS or 3G?

I want to connect two phones over 3G or GPRS to send a stream of data continually. One phone will act as client that will send data and the other phone will act as the server to receive and display the same data. Is it possible to stream data without using a server?
No. You will have to use some kind of server definitely.
Not really, I have been working on a similar project using TCP/UDP packets, but the big issue is with finding the other phone.
The best way is to use a system similar to O-Auth to connect with an external server on the internet
and send/recive data through that, but I don't have much experience with that.
My project used UDP to find a server on a wifi network and get its ip, then connect to it through tcp,
but you just as easily use a server on the web to do it over any mobile data connection.
If you wanted I will gladly send you some of my tcp code as a starting point.
Swift
You can't connect two devices directly though the cellular data. You need an intermediate server.
If on the other hand you are going to connect them through wifi, then you can use sockets to connect both of them together.
If the distance between both the devices is less, then you can also try out transfer over bluetooth.

Transfer data between two Android using Wifi

I'm trying to develop an Android application which have to be able to transfer data/message between two Android mobiles, as a client server connection using their own Wifi, which having no network or routers nearby. I just tried using Tcp program to do this but it fails, its not connecting, I'm getting ConnectException and connection refused.
[Edited] Is it possible to achieve this using Android Portable Hotspot integrated with application? Is there any tutorial regarding this approach?
Any Ideas, how to do this?
Thanks.
You need to get the two devices networked to each other before you can worry about tcp usage of that network connection.
If one device is willing to perform access-point like functionality as part of a portable hotspot, and you select that as a wirelss network on the other, you may achieve a network connection between the two that can be used for custom traffic. Though there are ways the hotspot could be implemented where that would not work. Also of concern, the "client" device will now be sending all of its network traffic through the hotspot device, including not just foreground apps but anything it decides to do in the background.

Categories

Resources