Android WiFi sending and receiving information - java

Sorry for kind of a dummy question, but I'm wondering how to work with WiFi connection via android. My application needs to transfer some data (both receiving and sending) with PC or with other android device using WiFi. How should I organize the process? I mean, how should I establish connection, then should I open a socket for data transfering, etc. Is there any way to do it without internet connection, smth like bluetooth, except wifi.p2p (which is only available for android 4.0)? Would be grateful for as detailed manual as possible.

Every network connection even if only in the local network or localhost reqieres the INTERNET permission.
Bluetooth and NFC might be an option, but I have no experiance with that.

Related

How can WebRTC reconnect to the same peer after internet disconnect?

I am working on a peer-to-peer Video call system based on WebRTC in android. my problem is I have no ideas how to reconnect video call when internet disconnect or switch from a network to other network (example switch from Wi-Fi to mobile)?
You will need to do an ICE Restart. You do this by calling restartIce and then generating a new offer for web.
See this answer for a specific android answer.

PC to Android communication over USB cable

I need to make communication between PC software (written in java) and android app over usb cable. The PC software will send some data (Strings) to Android app witch will accept those strings and do some action depending on the message received.
What is the best way to do this?
I am looking all over the internet and can't find any solution to this. If someone has example of this communication i would be very grateful.
I already done this communication over sockets, put i need to cover situation if there is no router or internet connection.
Thank you
Check following article. I guess similar question to your on SO.
If you want to communicate between Android USB device and some USB host you need to use the accessory mode (https://developer.android.com/guide/topics/connectivity/usb/). But this mode requires special driver support on the USB host side (which is your PC).

P2P communication , chat App (android)

i am using this tutorial as guide. i am creating an android app which is basically chat application. this uses socket programming to communicate .
i want to connect directly to device and deliver the message. the message does not go to server. server only tell me the address of the device thats it.
i followed the tutorial i mentioned above and this only works for the case where client and server are within same wifi/network. i want to connect to server from client irrespective of their network connection place. how do i do it from any network to any network.
i think i need to use port forwarding , but this is not practical . so we better use a server for keeping track of all the ip changes. and deliver the messages directly from the source to client. so how do i do it. please suggest any resources.
update
as of now what i studied is i have to use innetaddress to communicate if i am inside an wifi router.
thank you

Is it possible to transfer data directly between two android devices to other users in the same network?

Let's say I have two android mobile devices, connected to the same wireless network, and that network hasnt external/internet access.
Without third party software, is it possible to transfer data through wifi without knowing the ip from each other and without creating an hotspot? Something like we do on Windows (if 2 pcs are on same network, they can share information directly without internet access)
Starting with the basics, I would like to develop an application, where android phones on same network appears on a list , and then a user choose on of them and writes something - and if the other user have the same app running, appears that on his phone (and then he can reply of course - basically, a chat.
I know this make no practical sense, but believe makes all the sense for what I need to do (it's not a chat of course). If anyone knows anything, please help me - i found nothing.
Thanks in advance.
If you want to send data or messages from one phone to another using the network you will eventually need the IP address of the recipient phone. However, If you don't care about targeting specific phones you could always send UDP broadcast packets that each device on the network should receive.
If you don't want to manually specify an IP you'll need to create a discovery protocol that a phone uses to discover all the other phones on the network. You could do this buy scanning all available IP addresses and checking to see if they are a valid android phone. Or you could have each phone broadcast its presence on the network using a UDP broadcast packet sent to a predefined port.
Once you have discovered all the phones on the network its really up to you to decide how you want to send the data between phones and there are hundreds of examples of how to send data between devices/computers/processes using sockets.

Error Checking and Validation using Bluetooth in Java

Using Bluetooth I wish to communicate between a Windows PC and a mobile phone. The PC will probably have Bluecove while the mobile comes with JSR-82.
Do I have to implement CRC and other error checking procedures in my software related to Bluetooth transmission and reception or does the underlying Stack and hardware takes care of those details?
For instance if I send a message to another device over RFCOMM/SPP I need to be certain whether the message reached the device and whether it received exactly what I sent.
How can this be implemented or does this have to be checked in software?
RFCOMM is supposed to provide a reliable connection like tcp.
Data should arrive in the order it was sent, without corruption, or not at all.

Categories

Resources