WifiManager isWifiEnabled - 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 isWifiEnabled method.

This code example shows how to use the following methods:isWifiEnabled
	 *  
	 * @returns {boolean} The status of Wi-Fi in device settings. 
	 */ 
	public boolean isWifiEnabled() { 
		WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
		boolean result = wifiManager.isWifiEnabled();
		Log.d(LOG_TAG, "Wifi enabled: " + result);
		return result;
	} 
	 
	/** 
	 * Requests that the user enable the Wi-Fi in device settings. 
	 */ 
	public void switchToWifiSettings() { 
		Log.d(LOG_TAG, "Switch to Wifi Settings");
		Intent settingsIntent = new Intent(Settings.ACTION_WIFI_SETTINGS);
		ctx.startActivity(settingsIntent);
	} 
	 
	/** 
9
CodeRank
This code example shows how to use the following methods:isWifiEnabled
  } 
 
  @Test(expected = SecurityException.class) 
  public void isWifiEnabled_shouldThrowSecurityExceptionWhenAccessWifiStatePermissionNotGranted() throws Exception { 
    shadowWifiManager.setAccessWifiStatePermission(false);
    wifiManager.isWifiEnabled();
  } 
 
  @Test(expected = SecurityException.class) 
  public void getConnectionInfo_shouldThrowSecurityExceptionWhenAccessWifiStatePermissionNotGranted() throws Exception { 
    shadowWifiManager.setAccessWifiStatePermission(false);
    wifiManager.getConnectionInfo();
  } 
 
  @Test 
  public void shouldEnableNetworks() throws Exception { 
    int networkId = 666;
    wifiManager.enableNetwork(networkId, true);
    Pair<Integer, Boolean> lastEnabled = shadowWifiManager.getLastEnabledNetwork();
    assertThat(lastEnabled).isEqualTo(new Pair<Integer, Boolean>(666, true));
8
CodeRank
This code example shows how to use the following methods:isWifiEnabled
    } 
 
    @Test(expected = SecurityException.class) 
    public void isWifiEnabled_shouldThrowSecurityExceptionWhenAccessWifiStatePermissionNotGranted() throws Exception { 
        shadowWifiManager.setAccessWifiStatePermission(false);
        wifiManager.isWifiEnabled();
    } 
 
    @Test(expected = SecurityException.class) 
    public void getConnectionInfo_shouldThrowSecurityExceptionWhenAccessWifiStatePermissionNotGranted() throws Exception { 
        shadowWifiManager.setAccessWifiStatePermission(false);
        wifiManager.getConnectionInfo();
    } 
 
    @Test 
    public void shouldEnableNetworks() throws Exception { 
        int networkId = 666;
        wifiManager.enableNetwork(networkId, true);
        Pair<Integer, Boolean> lastEnabled = shadowWifiManager.getLastEnabledNetwork();
        assertThat(lastEnabled).isEqualTo(new Pair<Integer, Boolean>(666, true));
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:isWifiEnabled
		} 
		return cachedInstance;
	} 
	 
	public boolean isWifiEnabled() { 
		return wifiManager.isWifiEnabled();
	} 
	 
	public void turnOnWifi(boolean state) {
		wifiManager.setWifiEnabled(state);
	} 
	 
	public void enableMobileData(boolean state){
		try { 
			Method dataMtd = ConnectivityManager.class.getDeclaredMethod("setMobileDataEnabled", boolean.class);
			dataMtd.setAccessible(true);
			dataMtd.invoke(this.mdataManager, state);
		} catch (Exception e) {
			PreyLogger.e("Couldn't enable mobile data", e);
		} 
7
CodeRank
This code example shows how to use the following methods:isWifiEnabled, setWifiEnabled
        }         
         
        WifiManager wmgr = 
                (WifiManager)app.getSystemService(Context.WIFI_SERVICE);
         
        if (!wmgr.isWifiEnabled())
        { 
            app.log("Reenabling Wi-Fi");
            wmgr.setWifiEnabled(true);
        } 
    } 
} 
6
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:getWifiState, isWifiEnabled, setWifiEnabled, startScan

Related WifiManager isWifiEnabled Questions & Answers:

isWifiEnabled Method Overview
Return whether Wi-Fi is enabled or disabled.
See Code Examples for other Android WifiManager Methods: