I\'m currently using
public static String getLocalIPAddress(WifiManager wm){ return Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); }
open termux and run
ip -4 route get 8.8.8.8 | grep via
You'll something like this:
8.8.8.8 via 192.168.43.248 dev wlan0 table 1030 src 192.168.43.20 uid 12345