WifiManager getConnectionInfo - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for WifiManager getConnectionInfo method.

This code example shows how to use the following methods:getConnectionInfo
        WifiManager wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        shadowOf(wifiInfo).setMacAddress("mac address");
 
        wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
        wifiInfo = wifiManager.getConnectionInfo();
        assertThat(wifiInfo.getMacAddress()).isEqualTo("mac address");
    } 
} 
8
CodeRank
This code example shows how to use the following methods:getConnectionInfo
    shadowWifiManager = shadowOf(wifiManager);
  } 
 
  @Test 
  public void shouldReturnWifiInfo() { 
    assertEquals(wifiManager.getConnectionInfo().getClass(), WifiInfo.class);
  } 
 
  @Test(expected = SecurityException.class) 
  public void setWifiEnabled_shouldThrowSecurityExceptionWhenAccessWifiStatePermissionNotGranted() throws Exception { 
    shadowWifiManager.setAccessWifiStatePermission(false);
    wifiManager.setWifiEnabled(true);
  } 
 
  @Test(expected = SecurityException.class) 
  public void isWifiEnabled_shouldThrowSecurityExceptionWhenAccessWifiStatePermissionNotGranted() throws Exception { 
    shadowWifiManager.setAccessWifiStatePermission(false);
    wifiManager.isWifiEnabled();
  } 
 
8
CodeRank
This code example shows how to use the following methods:getConnectionInfo
        shadowWifiManager = shadowOf(wifiManager);
    } 
 
    @Test 
    public void shouldReturnWifiInfo() { 
        assertEquals(wifiManager.getConnectionInfo().getClass(), WifiInfo.class);
    } 
 
    @Test(expected = SecurityException.class) 
    public void setWifiEnabled_shouldThrowSecurityExceptionWhenAccessWifiStatePermissionNotGranted() throws Exception { 
        shadowWifiManager.setAccessWifiStatePermission(false);
        wifiManager.setWifiEnabled(true);
    } 
 
    @Test(expected = SecurityException.class) 
    public void isWifiEnabled_shouldThrowSecurityExceptionWhenAccessWifiStatePermissionNotGranted() throws Exception { 
        shadowWifiManager.setAccessWifiStatePermission(false);
        wifiManager.isWifiEnabled();
    } 
 
8
CodeRank
This code example shows how to use the following methods:addNetwork, disconnect, enableNetwork, getConnectionInfo, isWifiEnabled
        serverSocket.close();
        Log.d(TAG, "Server socket closed");
    } 
 
    public void connectToTheGame(String gameName) {
        if(wifiManager.isWifiEnabled()) {
            initialNetworkConfigId = wifiManager.getConnectionInfo().getNetworkId();
        } 
 
        WifiConfiguration wifiConfiguration = new WifiConfiguration();
        wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
        wifiConfiguration.SSID = "\"" + gameName + "\"";
 
        int netId = wifiManager.addNetwork(wifiConfiguration);
        wifiManager.disconnect();
        wifiManager.enableNetwork(netId, true);
        wifiManager.reconnect();
    } 
 
    public void stopLookingForWiFi() { 

7
CodeRank
This code example shows how to use the following methods:getConnectionInfo, getDhcpInfo, isWifiEnabled, setWifiEnabled
		// TODO Auto-generated constructor stub 
 
		WifiManager pWM = (WifiManager) xCtx
				.getSystemService(Service.WIFI_SERVICE);
 
		boolean wasWifiEnabled = pWM.isWifiEnabled();
 
		// Enable Wifi State if not 
		if (!wasWifiEnabled) {
			pWM.setWifiEnabled(true);
		} 
		Category c = new Category(xCtx, "NETWORKS");
		c.put("TYPE", "WIFI");
 
		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(),

7
CodeRank
This code example shows how to use the following methods:getConnectionInfo, isWifiEnabled
            setSupplicantStateText(state);
        } 
    } 
 
    private void handleNetworkStateChanged(NetworkInfo networkInfo) {
        if (mWifiManager.isWifiEnabled()) {
            String summary = Summary.get(this, mWifiManager.getConnectionInfo().getSSID(),
                    networkInfo.getDetailedState());
            mNetworkState.setText(summary);
        } 
    } 
 
    private final void updatePingState() { 
        final Handler handler = new Handler();
        // Set all to unknown since the threads will take a few secs to update. 
        mPingIpAddrResult = getResources().getString(R.string.radioInfo_unknown);
        mPingHostnameResult = getResources().getString(R.string.radioInfo_unknown);
        mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
 
        mPingIpAddr.setText(mPingIpAddrResult);
7
CodeRank
This code example shows how to use the following methods:getConnectionInfo, isWifiEnabled
 
        if (LOCAL_LOGD) {
            Log.d(TAG, "Received network state changed to " + networkInfo);
        } 
         
        if (mWifiManager.isWifiEnabled()) {
            String summary = WifiStatus.getStatus(mContext, 
                    mWifiManager.getConnectionInfo().getSSID(), networkInfo.getDetailedState());
            mWifiCheckBoxPref.setSummary(summary);
        } 
    } 
 
    private boolean isEnabledByDependency() { 
        Preference dep = getDependencyPreference();
        if (dep == null) {
            return true; 
        } 
         
        return !dep.shouldDisableDependents();
    } 
6
CodeRank
This code example shows how to use the following methods:getConnectionInfo
        shadowWifiManager = shadowOf(wifiManager);
    } 
 
    @Test 
    public void shouldReturnWifiInfo() { 
        assertEquals(wifiManager.getConnectionInfo().getClass(), WifiInfo.class);
    } 
 
    @Test(expected = SecurityException.class) 
    public void setWifiEnabled_shouldThrowSecurityExceptionWhenAccessWifiStatePermissionNotGranted() throws Exception { 
        shadowWifiManager.setAccessWifiStatePermission(false);
        wifiManager.setWifiEnabled(true);
    } 
 
    @Test(expected = SecurityException.class) 
    public void isWifiEnabled_shouldThrowSecurityExceptionWhenAccessWifiStatePermissionNotGranted() throws Exception { 
        shadowWifiManager.setAccessWifiStatePermission(false);
        wifiManager.isWifiEnabled();
    } 
 
7
CodeRank
This code example shows how to use the following methods:getConnectionInfo, getDhcpInfo
	}  
	 
	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");
6
CodeRank
This code example shows how to use the following methods:getConnectionInfo, getDhcpInfo, getWifiState, pingSupplicant
        send(getStatus()); 
    } 
     
    private static XmppMsg getStatus() { 
        XmppMsg res = new XmppMsg();
    	int status = sWifiManager.getWifiState();
    	String statusStr;
    	switch (status) {
    	case WifiManager.WIFI_STATE_DISABLED:
    		statusStr = "disabled";
    		break; 
    	case WifiManager.WIFI_STATE_DISABLING:
    		statusStr = "disabling";
    		break; 
    	case WifiManager.WIFI_STATE_ENABLED:
    		statusStr = "enabled";
    		break; 
    	case WifiManager.WIFI_STATE_ENABLING:
    		statusStr = "enabling";
    		break; 

6
CodeRank

Related WifiManager getConnectionInfo Questions & Answers:

getConnectionInfo Method Overview
Return dynamic information about the current Wi-Fi connection, if any is active.
See Code Examples for other Android WifiManager Methods: