How to determine wifi network interface name in java?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
If you're after the Wi-Fi interface and only the Wi-Fi interface, then parsing /proc/net/wireless is the way to go on Android:
Can you specify? Do you want the SSID of the connected network? Or the name of the network adapters? I provided an example to get the name of all network interfaces.
If you only want to select the WLAN Interface, maybe you have to do this via JNI, otherwise you could check the name for occurrences of "wlan" (like eth0, eth1 and so on). I don't recommend to rely only on this naming convention.
Try:
NetworkInterface.getNetworkInterfaces();
which will return all the interfaces present on your machine.
Since you said that you are developing on Android use this:
This will return the name of your WIFI.
You have to add this permission to your manifest.