String ipAddress = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()) WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE) NetworkInfo activeNetwork = cm.getActiveNetworkInfo() ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE) Please have a look on below code I am using right now.įirst of all fetch my own device IP address to check what subnet I have.This IP is used to ping other IPs. But sometimes few devices are not showing in list. I was also searching solution for this and tried lots of things.Īfter all search I follow Solution and its works fine.