I want to make an android app that connects with other devices and make voice communication , where one can speak while others listen . Is there a way to do it without internet connection or via bluetooth or wifi direct. Thanks for sharing if someone has some experience about this kind of app.
Success !
You can do it without internet connection.
I have already done this with wifi-direct and it works. You need to establish a wifi-direct connection then create socket on devices.
You can use AudioRecorder to acquire the voice and send it with an OutputStream link to the socket and you can receive the data in the other device with an Inputstream and interpret it with an AudioTrack.
Related
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 )
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.
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.
I want to start a local network connection using the built-in Wi-Fi hotspot on Android devices.
Is there a way to accomplish it?
And how to communicate between two devices?
EDIT:
I want to do it programmatically. Then I can transfer my own data between devices.
I haven't done this before, so my answer is all theoretical.
I think what you need to do is declare one device the server and start its hotspot manually with a known name.
Start / stop built-in Wi-Fi / USB tethering from code? (According to this question, you can't start hotspot programatically).
Once you have the hotspot set up, you start up the server app and wait for incoming connections. The server app can show you the ip address or hostname.
On the clients, you can do a simple check and see if the hotspot name is around and automatically connect to it if you find it. See this link for connecting to a network:
Using WifiManager to connect to a network
As for your second question, how to communicate - you need to establish a connection between the devices. For this, you need the ip address of the server. The simplest thing to do would be to show the ip address on the server UI and then manually enter it on the clients and press connect. It would then establish a connection to the server on a known port and you can send messages between client and server.
For reference, I found NanoHttpd, which is a webserver for Android. It uses ServerSocket to listen for incoming connections.
Possible answers:
Before ICS and non rooted devices
There is no way you can connect to a device over wifi. There is no API to do. Bluetooth is your best option or user interaction.
Before ICS and rooted devices
I am not sure if someone hacked the code, but when I tried to do an automatic connection to a wifi spot I noticed:
The api is hidden inside the SDK.
The method that does the connection checks the thread who ask for it. If it's not the os thread, it throws an exception.
Using ICS
With ICS there is a new way to connect devices through wifi called Wi-Fi Direct.
Here is a link with some demos.
If you are going to develop your own application for each and every individual terminals(devices) then i think for you socket programming will do the trick .
Yes , android supports socket programming in the same was as java socket programming .
1st google java socket programming tutorials and then you can using the same knowledge in android .
Also do remember to include the uses internet permission in the manifest , actually thats something which ate my brains for a long time :)
You mean communication between wifi enabled devices without any server like p2p? if so its wifi direct which is supported in ICS check this out http://developer.android.com/reference/android/net/wifi/p2p/package-summary.html
Before ICS there is no standard android API for wifi direct, though Galaxy S2 has wifi direct it uses proprietary API's which 3rd party devs can't use.
i dont know programmically create wify LAN,but you can create wify LAN manually,then you can do java tcp/udp program as said by brianestey
"As for your second question, how to communicate - you need to establish a connection between the devices. For this, you need the ip address of the server. The simplest thing to do would be to show the ip address on the server UI and then manually enter it on the clients and press connect. It would then establish a connection to the server on a known port and you can send messages between client and server."
for manual connection follow the steps
take settings/wireless&networks/portable wi-fi hotspot settings from any one of the phone
create new hotspot and turn on wi-fi portable hotspot from there
connect all other device to that hotspot including your pc
you will get ip of each device programmically (includig pc,but i dont know)
I am trying to use Bluetooth SPP to communicate over it. In some Android phones, SPP profile is not activated. I faced the problem in the application that SPP was not activated and so the connection could not be established over bluetooth and when I started another app that is 3g hotspot which I think activates SPP and I was able to connect over bluetooth in my app.
So, how can we actually activate SPP profile of bluetooth in Android devices? And does all the android devices has SPP profile?
In developer.android.com BluetoothSocket:
The most common type of Bluetooth
socket is RFCOMM, which is the type
supported by the Android APIs. RFCOMM
is a connection-oriented, streaming
transport over Bluetooth. It is also
known as the Serial Port Profile
(SPP).
This might answer your question ..
https://source.android.com/devices/bluetooth/services
SPP (or ability to use Java API's to establish RFCOMM channels) is available from Android (2.0/2.1) release (Eclair) onwards
On the Android phone you will probably need to run an application that initiates the service over SPP.
**
public BluetoothServerSocket
listenUsingRfcommWithServiceRecord
(String name, UUID uuid)
** API can be used to create a service with specified UUID to listen,
Doing this should make this service visible to other devices which can then connect to it.
I just called Samsung help regarding bluetooth SPP on an S8+ phone. They tell me wait for Android Oreo as it isn't available till then. My previous Sony Xperia used Ntrip Client to talk to an external Geneq GPS to receive corrected coordinates and worked really well. Seems we went backwards somewhere?
Ntrip client on the phone collects an internet data stream of GPS corrections every five seconds and sends these to the GPS. The GPS uses the corrections and sends back adjusted coordinates to the phone to use in any application.
I would appreciate someone brighter than me pointing out a quick fix I just load and run to bring back this functionality.