This article describes the Android programming implementation to get the currently connected WiFi name method. Share to everyone for your reference, specific as follows:
Wifimanager wifimgr = (wifimanager) mactivity.getsystemservice (Context.wifi_service);
int wifistate = Wifimgr.getwifistate ();
Wifiinfo info = Wifimgr.getconnectioninfo (); String wifiid = info!= null?
INFO.GETSSID (): null;
public static inetaddress Getwifiip () {Context mycontext = Globals.getcontext ();
if (mycontext = = null) {throw new NullPointerException ("Global context is null");
} Wifimanager wifimgr = (wifimanager) mycontext.getsystemservice (Context.wifi_service);
if (iswifienabled ()) {int ipasint = Wifimgr.getconnectioninfo (). getipaddress ();
if (Ipasint = = 0) {return null;
else {return util.inttoinet (ipasint);
} else {return null;
}//Get WiFi IP address inetaddress adress = FTPSERVERSERVICE.GETWIFIIP ();
Address.gethostaddress ();
public static Boolean iswifienabled () {Context mycontext = Globals.getcontext ();
if (mycontext = = null) {throw new NullPointerException ("Global context is null"); } Wifimanager wifimgr = (wifimanager) mycontext. Getsystemservice (Context.wifi_service); if (wifimgr.getwifistate () = = wifimanager.wifi_state_enabled) {Connectivitymanager Connmanager = (ConnectivityManager
) mycontext. Getsystemservice (Context.connectivity_service);
Networkinfo wifiinfo = Connmanager. Getnetworkinfo (Connectivitymanager.type_wifi);
return wifiinfo.isconnected ();
else {return false;
}//Open WIFI Settings page Intent Intent = new Intent (Android.provider.Settings.ACTION_WIFI_SETTINGS);
StartActivity (Intent);
I hope this article will help you with your Android programming.