I want to exchange data over hotspot between two android devices. I've tried to properly connection.
1st. I created portable hotspot:
Network SSID - my_hotspot2nd. I'm attempting to connect when application is launched. Here is my code
mWifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + networkSSID + "\"";
conf.wepKeys[0] = "\"" + networkPass + "\"";
conf.wepTxKeyIndex = 0;
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
conf.preSharedKey = "\""+ networkPass +"\"";
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
int res = mWifiManager.addNetwork(conf);
boolean b = setWifiApEnabled(null, true);
I assume it was unsuccessfully. Then i'm trying sending data via socket. I've learned from JavaCodeGeeks. I configured SERVER_IP 192.168.49.1, SERVER_PORT:8888.
How to communicate correctly between two Android devices using hotspot?
Thanks in advance.
You can use your phone's mobile data to connect another phone, tablet, or computer to the internet. Sharing a connection this way is called tethering or using a hotspot. Some phones can share Wi-Fi connection by tethering. Most Android phones can share mobile data by Wi-Fi, Bluetooth, or USB.
No, It's not possible at all. In fact you cannot connect ANY end device such as Mobile, Laptop, Desktop or Tablet to two internet connection.
Why don't you use Wi-Fi Direct? It is a p2p protocol. You can share data between two Android devices without any need of hotspot. It uses android.net.wifi.p2p package.
Wi-Fi peer-to-peer (P2P) allows Android 4.0 (API level 14) or later devices with the appropriate hardware to connect directly to each other via Wi-Fi without an intermediate access point (Android's Wi-Fi P2P framework complies with the Wi-Fi Alliance's Wi-Fi Direct™ certification program). Using these APIs, you can discover and connect to other devices when each device supports Wi-Fi P2P, then communicate over a speedy connection across distances much longer than a Bluetooth connection. This is useful for applications that share data among users, such as a multiplayer game or a photo sharing application.
You can find more information on Android developer site about this technology. Here are some useful links:
Android Wi-Fi p2p
android.net.wifi.p2p package
Creating the application
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With