This article describes the Android programming method to obtain the current connection wifi name. Share it for your reference, as follows:
WifiManager wifiMgr = (WifiManager) (Context.WIFI_SERVICE); int wifiState = (); WifiInfo info = (); String wifiId = info != null ? () : null; public static InetAddress getWifiIp() { Context myContext = (); if (myContext == null) { throw new NullPointerException("Global context is null"); } WifiManager wifiMgr = (WifiManager) (Context.WIFI_SERVICE); if (isWifiEnabled()) { int ipAsInt = ().getIpAddress(); if (ipAsInt == 0) { return null; } else { return (ipAsInt); } } else { return null; } } // Get the wifi IP addressInetAddress address = (); (); public static boolean isWifiEnabled() { Context myContext = (); if (myContext == null) { throw new NullPointerException("Global context is null"); } WifiManager wifiMgr = (WifiManager) (Context.WIFI_SERVICE); if (() == WifiManager.WIFI_STATE_ENABLED) { ConnectivityManager connManager = (ConnectivityManager) myContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiInfo = connManager .getNetworkInfo(ConnectivityManager.TYPE_WIFI); return (); } else { return false; } } // Open the wifi settings pageIntent intent = new Intent(.ACTION_WIFI_SETTINGS); startActivity(intent);
I hope this article will be helpful to everyone's Android programming design.