Transfer Data over wifi in android between server and clients - android

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.

Related

Best and safe way to conect Arduino and Android

I'm developing an application that communicates with Arduino (Arduino Uno), I used two ways to communicate so far, via :
1. USB (I used the usb-serial-for-android and Physicaloid libraries) and
2. Bluetooth, sending and receiving data.
Via Bluetooth was a little slow and sometimes the information was simply not sent or received, the USB communication sending data was pretty fast, but still, sometimes the connection does not open, and it's very random, run the application and USB connection does not open, close the application, run again and the connection open, have not tried connecting via Wifi.
My question is this, what is the ideal and safest way to perform connection with Arduino?
Bluetooth connection is best, because HC05 adapters are dirt cheap and those use UART for communication (the same as com- port )

Exchanging data over a WiFi Hotspot between an iOS device and Android device

The problem is:
Having an Android device with turns on Personal Hotspot(WiFi/ad-hoc network).
Having an iOS device which connects to the Android's WiFi network.
Is there a possibility to exchange data between the same app build by a developer on both platforms?
If not, is there any way to exchange data between the same app running on both platforms using the current technologies on iOS and Android(so, without using internet connection or tech such as Near field communication)?
Already researched about data exchange using bluetooth which resulted in this.
Started researching about peer-to-peer connection but as its written on the first paragraph of the Multipeer Connectivity, it says "..by nearby iOS devices..".
(Android) Wi-Fi Peer-to-Peer
(iOS) Multipeer Connectivity
Working on an application and there i am using the socket concept to send receive data from connected peer. All you need to do is
Create hotspot network
Allow nearby devices to connect
Send broadcast message like we send in chat. e.g User joined. And in that message send file which you want to download.
Other side in connected peer, Search file in local if exists use output stream to write the data and after writing the whole data just flush it to other side,
Active listener will receive the data in input stream then.
Hope it helps.

Receiving data through wifi connection

I'm trying to make the following work, and wonder if it is possible:
I want to send data from a hardware piece to an android device. Although the hardware only has an Ethernet connection available.
If I were to make an Ethernet connection from the hardware piece to a router, and then communicate from the router to the android device with WiFi, is there any way I could tell the android device, just receive data from the WiFi?
Using IP protocol will allow you to communicate over any IP network.
Easiest way to do that is using TCP sockets that uses Server/Client relation to communicate.
I'm guessing you are using a microcontroller (arduino?) if that is the case there are many IP labraries and examples you can look at.
after writing the server code on the hardware then you can easily use sockets to connect to it from android, here is an example on how to connect android client to TCP server.
TCP Client tutorial
Extra links:
TCP on Wikipedia no need to read the implimentation details just understand the concept.
Java All about Sockets Great overview of socket programming and should get you ready to write effective code on the android side.
LAN wikipedea article about LANs

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.

Android phone development - UDP services

I'm interested in the viability of implementing an Android application that interacts with a UDP service. I'm sure Android supports UDP:
http://www.helloandroid.com/tutorials/simple-udp-communication-example
What I'm less clear about is whether or not such an application would actually work on an Android phone on a typical tariff - for bidirectional communication. I want the Android client to contact a remotely hosted service by UDP (announcing itself) and for the server to subsequently notify the Android device about real-time events.
I'm concerned that a mobile device on a commercial network might be forced to change IP address - for example - when moving in/out of a Wi-Fi zone... and I'm unclear if NAT would be a problem on a typical 3G network.
Is it really viable to use UDP for bi-directional (best-effort) communications both to and from an Android phone?
There are a few issues for you to look at here. First, UDP is perfectly useable by Android. It can send and receive UDP packets just fine. The larger issue is really that the phone cannot receive incoming UDP connections that it did not open the initial connection for, unless it is on WiFi and rhe connection is coming from the same LAN.
On 3G/4G the phone is not addressable from the outside because the Wireless carrier has in place a firewall with a proxy server. So, incoming connections are not passed over that firewall. If, instead the phone opens the connection from behind the firewall, then bidirectional traffic can flow over that link.
Now, the problem you will have will be
1) Keeping the link alive when the phone goes from network (3G) to network (Wifi)
2) Battery life from the constantly open connection
Most likely, you really want C2DM for what you are looking at.

Categories

Resources