我想在两个Android设备之间通过热点交换数据.我试过正确连接.
1.我创建了便携式热点:
网络SSID - my_hotspot第2位.我正在尝试连接应用程序启动时.在这里我的代码
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);
Run Code Online (Sandbox Code Playgroud)
我认为它没有成功.然后我正在尝试通过套接字发送数据.我从JavaCodeGeeks那里学到了很多东西.我配置了SERVER_IP 192.168.49.1,SERVER_PORT:8888.
如何使用热点在两个Android设备之间正确通信?
提前致谢.