Android WifiInfo - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android WifiInfo class.

This code example shows how to use the following methods:getMacAddress
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        shadowOf(wifiInfo).setMacAddress("mac address");
 
        wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
        wifiInfo = wifiManager.getConnectionInfo();
        assertThat(wifiInfo.getMacAddress()).isEqualTo("mac address");
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getBSSID, getLinkSpeed, getMacAddress, getSSID
    public boolean getWifiInfo() { 
        WifiManager wifi = (WifiManager) ctxt.getSystemService(Context.WIFI_SERVICE);
        if (wifi != null) {
            info = wifi.getConnectionInfo();
            // Set wifi variables 
            speed = info.getLinkSpeed();
            ssid = info.getSSID();
            bssid = info.getBSSID();
            macAddress = info.getMacAddress();
            gatewayIp = getIpFromIntSigned(wifi.getDhcpInfo().gateway);
            // broadcastIp = getIpFromIntSigned((dhcp.ipAddress & dhcp.netmask) 
            // | ~dhcp.netmask); 
            netmaskIp = getIpFromIntSigned(wifi.getDhcpInfo().netmask);
            return true; 
        } 
        return false; 
    } 
 
    public String getNetIp() {
        int shift = (32 - cidr);
7
CodeRank
This code example shows how to use the following methods:getBSSID, getHiddenSSID, getIpAddress, getLinkSpeed, getMacAddress
		WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
		WifiInfo wifiInfo = wifiManager.getConnectionInfo();
		 
		JSONObject obj = new JSONObject();
		try { 
			obj.put("BSSID", wifiInfo.getBSSID());
			obj.put("HiddenSSID", wifiInfo.getHiddenSSID());
			obj.put("SSID", wifiInfo.getSSID());
			obj.put("MacAddress", wifiInfo.getMacAddress());
			obj.put("IpAddress", wifiInfo.getIpAddress());
			obj.put("NetworkId", wifiInfo.getNetworkId());
			obj.put("RSSI", wifiInfo.getRssi());
			obj.put("LinkSpeed", wifiInfo.getLinkSpeed());
			 
		} catch (JSONException e) {
			e.printStackTrace();
			callbackContext.error("JSON Exception");
		} 
		callbackContext.success(obj);
		return true; 
7
CodeRank
This code example shows how to use the following methods:getIpAddress, getMacAddress
	 
	private void updateWifi(){ 
		wifi=new Wifi();
		WifiManager wifiMgr = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
		WifiInfo wifiInfo= wifiMgr.getConnectionInfo();
		String macAddress=wifiInfo.getMacAddress();
		if (macAddress==null){
			wifi=null;
		}else{ 
		int ipAddress=wifiInfo.getIpAddress();
		wifi.setIpAddress(formatterIp(ipAddress));
		wifi.setMacAddress(macAddress);
		DhcpInfo dhcpInfo= wifiMgr.getDhcpInfo();
		wifi.setNetmask(formatterIp(dhcpInfo.netmask));
		wifi.setGatewayIp(formatterIp(dhcpInfo.serverAddress));
		if(ipAddress!=0)
			wifi.setInterfaceType("Wireless");
		else 
			wifi.setInterfaceType("3G");
		wifi.setName("eth0");
7
CodeRank
This code example shows how to use the following methods:getBSSID, getIpAddress, getLinkSpeed, getRssi, getSSID
    	res.appendLine(supplicant_status);
    	 
    	WifiInfo info = sWifiManager.getConnectionInfo();
    	if (info != null) {
    	    res.newLine();
    	    String bssid = info.getBSSID();
    	    String ip = Tools.ipIntToString(info.getIpAddress());
    	    String ssid = info.getSSID();
    	    int rssi = info.getRssi();
    	     
    	    // bssid 
    	    res.appendBold("BSSID: ");
    	    res.appendLine(bssid);
    	    // ssid 
    	    res.appendBold("SSID: ");
    	    res.appendLine(ssid);
    	    // ip 
    	    res.appendBold("IP: ");
    	    res.appendLine(ip);
    	    // link speed 

6
CodeRank
This code example shows how to use the following methods:getIpAddress, getLinkSpeed, getMacAddress, getRssi, getSSID
	} 
	 
	private void get_wifi() { 
		WifiInfo info = wifi.getConnectionInfo();
		int state = wifi.getWifiState();
		int strength = WifiManager.calculateSignalLevel(info.getRssi(), 5);
		boolean enabled = wifi.isWifiEnabled();
		 
		name_label.setText(info.getSSID());
		enable_label.setText(enabled ?"Your wifi is enabled" :"Your wifi is not enabled");
		state_button.setText(enabled ?"Disable wifi" : "Enable wifi");
		 
		switch(state) {
			case WifiManager.WIFI_STATE_ENABLED:
				data_labels[WIFISTATE].setText(" Enabled");
				break; 
			case WifiManager.WIFI_STATE_DISABLED:
				data_labels[WIFISTATE].setText(" Disabled");
				break; 
			case WifiManager.WIFI_STATE_DISABLING:

6
CodeRank
This code example shows how to use the following methods:getBSSID, getLinkSpeed, getMacAddress, getSSID
 
		DhcpInfo dhcp = pWM.getDhcpInfo();
		WifiInfo wifi = pWM.getConnectionInfo();
 
		FusionInventory.log(this, "<===WIFI INFO===>", Log.VERBOSE);
		if (wifi.getMacAddress() != null) {
			FusionInventory.log(this, "Mac Adress=" + wifi.getMacAddress(),
					Log.VERBOSE);
			c.put("MACADDR", wifi.getMacAddress());
		} 
		FusionInventory.log(this, "Link Speed=" + wifi.getLinkSpeed()
				+ WifiInfo.LINK_SPEED_UNITS, Log.VERBOSE);
		c.put("SPEED", String.valueOf(wifi.getLinkSpeed()));
		if (wifi.getBSSID() != null) {
			c.put("BSSID", String.valueOf(wifi.getBSSID()));
		} 
		if (wifi.getSSID() != null) {
			c.put("SSID", String.valueOf(wifi.getBSSID()));
		} 
 

6
CodeRank
This code example shows how to use the following methods:getBSSID, getHiddenSSID, getIpAddress, getLinkSpeed, getMacAddress
    OnClickListener updateButtonHandler = new OnClickListener() {
        public void onClick(View v) { 
            final WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); 
 
            setWifiStateText(mWifiManager.getWifiState()); 
            mBSSID.setText(wifiInfo.getBSSID()); 
            mHiddenSSID.setText(String.valueOf(wifiInfo.getHiddenSSID())); 
            int ipAddr = wifiInfo.getIpAddress(); 
            StringBuffer ipBuf = new StringBuffer(); 
            ipBuf.append(ipAddr  & 0xff).append('.'). 
                append((ipAddr >>>= 8) & 0xff).append('.'). 
                append((ipAddr >>>= 8) & 0xff).append('.'). 
                append((ipAddr >>>= 8) & 0xff); 
 
            mIPAddr.setText(ipBuf); 
            mLinkSpeed.setText(String.valueOf(wifiInfo.getLinkSpeed())+" Mbps"); 
            mMACAddr.setText(wifiInfo.getMacAddress()); 
            mNetworkId.setText(String.valueOf(wifiInfo.getNetworkId())); 
            mRSSI.setText(String.valueOf(wifiInfo.getRssi())); 
            mSSID.setText(wifiInfo.getSSID()); 

6
CodeRank
This code example shows how to use the following methods:getBSSID, getIpAddress, getLinkSpeed, getMacAddress, getRssi
        WifiManager myWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        WifiInfo myWifiInfo = myWifiManager.getConnectionInfo();
        mWifiInfoModel = new WifiInfoModel();
 
 
        mWifiInfoModel.setMac(myWifiInfo.getMacAddress());
 
        int myIp = myWifiInfo.getIpAddress();
 
        int intMyIp3 = myIp/0x1000000;
        int intMyIp3mod = myIp%0x1000000;
 
        int intMyIp2 = intMyIp3mod/0x10000;
        int intMyIp2mod = intMyIp3mod%0x10000;
 
        int intMyIp1 = intMyIp2mod/0x100;
        int intMyIp0 = intMyIp2mod%0x100;
 
        mWifiInfoModel.setIp(String.valueOf(intMyIp0)
                + "." + String.valueOf(intMyIp1)

6
CodeRank
This code example shows how to use the following methods:getIpAddress
 
		// figure out our wifi address, otherwise bail 
		WifiManager wifi = (WifiManager) getSystemService( Context.WIFI_SERVICE );
 
		WifiInfo wifiinfo = wifi.getConnectionInfo();
		int intaddr = wifiinfo.getIpAddress();
 
		byte[] byteaddr = new byte[] { 
			(byte) ( intaddr & 0xff ),
			(byte) ( intaddr >> 8 & 0xff ),
			(byte) ( intaddr >> 16 & 0xff ),
			(byte) ( intaddr >> 24 & 0xff )
		}; 
		InetAddress addr = InetAddress.getByAddress( byteaddr );
		Log.d( TAG, "startProbe : wifi address=" + addr.toString() );
 
		// start multicast lock 
		mLock = wifi.createMulticastLock( "mythtv_lock" );
		mLock.setReferenceCounted( true );
		mLock.acquire();
6
CodeRank

Related Android WifiInfo Questions & Answers:

See Code Examples for Android WifiInfo Methods: