I want to get the wlan0 inet address through code in Kotlin for my android app. I have tried using WifiManager.connectionInfo.ipAddress
, however that returned on both wifi and hotspot. However, if I run ifconfig
in termux, an IP exists. I also tried using InetAddress
class but that doesn't seem to have anything that works for my purpose.
I tried the solutions in this post: How to invoke external command from within Kotlin code?. Again, these returned nothing when passing in ifconfig
.