baidusoso / wifitransfer Goto Github PK
View Code? Open in Web Editor NEWWIFI传书,参考《多看》的WIFI传书功能,HttpServer采用AndroidAsync实现
WIFI传书,参考《多看》的WIFI传书功能,HttpServer采用AndroidAsync实现
File transfer through hotspot
This project transfers files through wifi to pc.
I want to sent the files through both wifi and hotspot.
This shares files with wifi IP.
public static String getWifiIp(@NonNull Context context) {
WifiManager wifimanager = (WifiManager) context.getApplicationContext().getSystemService
(Context.WIFI_SERVICE);
if (wifimanager == null) {
return null;
}
WifiInfo wifiInfo = wifimanager.getConnectionInfo();
if (wifiInfo != null) {
return intToIp(wifiInfo.getIpAddress());
}
return null;
}
private static String intToIp(int i) {
return (i & 0xFF) + "." + ((i >> 8) & 0xFF) + "." + ((i >> 16) & 0xFF) + "." + ((i >> 24)
& 0xFF);
}
public static NetworkInfo.State getWifiConnectState(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context
.CONNECTIVITY_SERVICE);
if (manager == null) {
return NetworkInfo.State.DISCONNECTED;
}
NetworkInfo mWiFiNetworkInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (mWiFiNetworkInfo != null) {
return mWiFiNetworkInfo.getState();
}
return NetworkInfo.State.DISCONNECTED;
}
This code used to get the IP address of wifi. I want to share files through both wifi and hotspot. So, I replaced this code to get both wifi and hotspot IP.
public void getDeviceIpAddress() {
try {
for (Enumeration<NetworkInterface> enumeration = NetworkInterface
.getNetworkInterfaces(); enumeration.hasMoreElements();) {
NetworkInterface networkInterface = enumeration.nextElement();
for (Enumeration<InetAddress> enumerationIpAddr = networkInterface
.getInetAddresses(); enumerationIpAddr
.hasMoreElements();) {
InetAddress inetAddress = enumerationIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()
&& inetAddress.getAddress().length == 4) {
tvServerIP.setText(inetAddress.getHostAddress());
}
}
}
} catch (SocketException e) {
Log.e("ERROR:", e.toString());
}
}
I tried with this code, but it didn't work.
How can I do this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.