I need a tutorial on how to process data on android via wifi. F.e., I need to send some message to PC and receive some other message. How should I establish the connection? What should I do to be able to transfer data and how?
Sorry for the dummy question, but I can't find good manual. I'll be grateful for as detailed manual as possible, or for ome simple example on etablishing wifi connection and sending/receiving simple mesages.
You don't have to use any API for connect to wifi its only requires if you want to manually start your wifi in device,
Just make sure your device has a WiFi enable, and make a simple TCP/IP Socket application. With this you can communication with your system and device, And Use System's public IP to connect with your system.
Also don't forget to give permission Internet in your manifest file..
Here some nice links for Socket Programing in Android..
Simple connection example part II - TCP communication
Networking with Android
Simple communication using java.net.Socket
http://www.anddev.org/tcp_sockets-t276.html
http://www.anddev.org/socket_programming-t325-s30.html
EDIT:: Android WiFi examples,
Scan for Wireless Networks
Using WiFi API
SO Question Android: Is there any way to get notified when known wifi networks get in/out of range?
Related
My Android App is communicating with Arduino HTTP server over WiFi. I need to change communication way from WiFi to USB OTG. I'm beginner in this area so my question is: When I change to USB OTG can I still use http request from Android app to Arduino server ? It will be working as before or is it not possible ?
surely it won't be working out-of-the-box, USB isn't IP protocol, thus HTTP isn't applicable to this transport. use UsbDeviceConnection and UsbInterface, still you can use currenlty used data structure, only transport will change. some DOCs about USB in HERE
I am working on an app that will act as a dashboard for an electronic card installed in cars and trucks.
I need the application to be able to receive data from this card, so I can display it in various ways on the app.
We chose Wifi for the communication method. To access the card, my app is able to connect to a Wifi network created by it.
I would like to receive JSON sent by the card every second.
I need help on where to start to make the two devices communicate, and what are the good practices on implementing this kind of communication.
The app basically act as a client, and the card as a server.
I found something about sockets, but it seemed to use two Android devices, a server and a client, so I'm kinda stuck here.
I use Android Studio 2.1.2 with the Android APIs ranging from 19 to latest.
One option is to broadcast with UDP the data within the local network. The moment the android device connects to the wifi network it will be in its local network. So the data can be received at the android end with a multicast receiver(check out http://jgroups.org/ ).
Refer example
It may also use the p2p sharing with TCP and bind the device with static IPs for communication. Create a simple socket receiver at the android end and a service at the device end. Depends on the way you choose it.
I have a question about the p2p functionality of Android OS (4.x and higher). I have a PC program that makes use of the Boost C++ library that can function as a server or as a client. Now i have a Android app that has a server using Java sockets. This program need a accesspoint to connect to each other.
I'm looking for a way to connect the Android server and the PC client program without a accesspoint. After looking around i found out that Android has a p2p library.
Android P2P
As a read it you can only connect two Android devices with each other, my question is if it is possible to use this library to connect the Android device to the PC using wifi p2p? Or if there is a other possiblity? All suggestions are welcome!
Roy, have a look at this: http://en.wikipedia.org/wiki/Wi-Fi_Direct
WiFi P2P is now called WiFi Direct, and it is indeed possible to connect two devices as long as one of the devices supports it. So Android device in P2P mode and a PC without any special configuraiton should work fine. However, the PC can (probably) only connect to one access point at a time, from its perspective the Android device is the access point, it would have to disconnect from its usual access point to connect to the Android device.
Also check out SoftAP.
I have android application the scan a Bluetooth device around, and connect them to start exchanging text.
I want the application to establish a communication with each Bluetooth device in the surrounding area and send text to all of them at once.
Is that possible to have multiple communication in android ? and if you have any examples ?
For sure it is possible. You are talking about Bluetooth BR/EDR (2.x, 3.0) or Bluetooth low energy(4.0)?
For Bluetooth BR/EDR, use the official documentation to get started.
Just do a SDP to find all devices in range that support your UUID. Here is how.
Then connect to each of them using a RFCOMM Connection as a client.
Obviously, the other devices should accept this connection. If those are Android as well, see the 'connecting as a server' chapter. (Basically it means waiting for a connection...).
For things not covered in the Android Official Documentation, see this.
You can also just take all paired devices, and try to connect to them(obviously only those in range will connect).
I want to develop an chat application to chat between two or more android devices using wifi network.The application should be able to send or receive strings from each other. I have an experience of using Bluetooth network between pc and android. Can any give me any suggestion or right direction. Thanks in advance.
You can be able to chat between two android devices in Android Version 4.0.There is an API called 'Wifi P2P'.More information can be had from here:
http://developer.android.com/reference/android/net/wifi/p2p/package-summary.html
If you are thinking about connecting devices that are under the same WiFi AP/router and without setting up any server, then I would suggest you to consider using UDP multicast which has been available since API level 1:
http://developer.android.com/reference/java/net/MulticastSocket.html
UDP does not guarantee data delivery (could be lost), so I would use UDP multicast for device discovery, and open up a TCP connection for data that requires guaranteed delivery. TCP listening port can be advertised via UDP multicast so that everyone can connect with each other over TCP. (There may be 3rd party tool that does this low level stuff for you.)
maybe XMPP will help, google talk uses the same protocol.
The Extensible Messaging and Presence Protocol (XMPP) is an open
technology for real-time communication, which powers a wide range of
applications including instant messaging, presence, multi-party chat,
voice and video calls, collaboration, lightweight middleware, content
syndication, and generalized routing of XML data.
things you need to do:
1. you need a server computer to run XMPP server, there are lots of open source implementations.
2. you need a XMPP client running on your android device, there are also lots of open source implementations running on android platform.