Java Code Examples for android.net.wifi.WifiManager#WIFI_STATE_DISABLING

The following examples show how to use android.net.wifi.WifiManager#WIFI_STATE_DISABLING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WifiStateReceiver.java    From WifiUtils with Apache License 2.0 7 votes vote down vote up
@Override
public void onReceive(Context context, @NonNull Intent intent) {
    int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);

    switch (wifiState) {
        case WifiManager.WIFI_STATE_ENABLED:
            wifiStateCallback.onWifiEnabled();
            break;
        case WifiManager.WIFI_STATE_ENABLING:
            break;
        case WifiManager.WIFI_STATE_DISABLING:
            break;
        case WifiManager.WIFI_STATE_DISABLED:
            break;
    }
}
 
Example 2
Source File: WifiManagerSnippet.java    From mobly-bundled-snippets with Apache License 2.0 6 votes vote down vote up
@Rpc(description = "Turns on Wi-Fi with a 30s timeout.")
public void wifiEnable() throws InterruptedException, WifiManagerSnippetException {
    if (mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED) {
        return;
    }
    // If Wi-Fi is trying to turn off, wait for that to complete before continuing.
    if (mWifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLING) {
        if (!Utils.waitUntil(
                () -> mWifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLED,
                TIMEOUT_TOGGLE_STATE)) {
            Log.e(String.format("Wi-Fi failed to stabilize after %ss.", TIMEOUT_TOGGLE_STATE));
        }
    }
    if (!mWifiManager.setWifiEnabled(true)) {
        throw new WifiManagerSnippetException("Failed to initiate enabling Wi-Fi.");
    }
    if (!Utils.waitUntil(
            () -> mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED,
            TIMEOUT_TOGGLE_STATE)) {
        throw new WifiManagerSnippetException(
                String.format(
                        "Failed to enable Wi-Fi after %ss, timeout!", TIMEOUT_TOGGLE_STATE));
    }
}
 
Example 3
Source File: WifiStateChangeService.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
private String printWifiState(int wifiState) {
    switch (wifiState) {
        case WifiManager.WIFI_STATE_DISABLED:
            return "WIFI_STATE_DISABLED";
        case WifiManager.WIFI_STATE_DISABLING:
            return "WIFI_STATE_DISABLING";
        case WifiManager.WIFI_STATE_ENABLING:
            return "WIFI_STATE_ENABLING";
        case WifiManager.WIFI_STATE_ENABLED:
            return "WIFI_STATE_ENABLED";
        case WifiManager.WIFI_STATE_UNKNOWN:
            return "WIFI_STATE_UNKNOWN";
        case Integer.MIN_VALUE:
            return "previous value unset";
        default:
            return "~not mapped~";
    }
}
 
Example 4
Source File: SwapWorkflowActivity.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    setUpFromWifi();

    int wifiStatus = -1;
    TextView textWifiVisible = container.findViewById(R.id.wifi_visible);
    if (textWifiVisible != null) {
        intent.getIntExtra(WifiStateChangeService.EXTRA_STATUS, -1);
    }
    switch (wifiStatus) {
        case WifiManager.WIFI_STATE_ENABLING:
            textWifiVisible.setText(R.string.swap_setting_up_wifi);
            break;
        case WifiManager.WIFI_STATE_ENABLED:
            textWifiVisible.setText(R.string.swap_not_visible_wifi);
            break;
        case WifiManager.WIFI_STATE_DISABLING:
        case WifiManager.WIFI_STATE_DISABLED:
            textWifiVisible.setText(R.string.swap_stopping_wifi);
            break;
        case WifiManager.WIFI_STATE_UNKNOWN:
            break;
    }
}
 
Example 5
Source File: Wifi.java    From batteryhub with Apache License 2.0 6 votes vote down vote up
/**
 * Get Wifi state.
 *
 * @param context The Context
 * @return Wifi state constant, an int value
 */
public static String getState(Context context) {
    WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    int wifiState = manager.getWifiState();

    switch (wifiState) {
        case WifiManager.WIFI_STATE_DISABLED:
            return WIFI_STATE_DISABLED;
        case WifiManager.WIFI_STATE_DISABLING:
            return WIFI_STATE_DISABLING;
        case WifiManager.WIFI_STATE_ENABLED:
            return WIFI_STATE_ENABLED;
        case WifiManager.WIFI_STATE_ENABLING:
            return WIFI_STATE_ENABLING;
        case WifiManager.WIFI_STATE_UNKNOWN:
            return WIFI_STATE_UNKNOWN;
        default:
            return WIFI_STATE_UNKNOWN;
    }
}
 
Example 6
Source File: DLNAService.java    From AndroidVideoPlayer with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onReceive(Context c, Intent intent) {
	Bundle bundle = intent.getExtras();
	int statusInt = bundle.getInt("wifi_state");
	switch (statusInt) {
	case WifiManager.WIFI_STATE_UNKNOWN:
		break;
	case WifiManager.WIFI_STATE_ENABLING:
		break;
	case WifiManager.WIFI_STATE_ENABLED:
		LogUtil.e(TAG, "wifi enable");
		startThread();
		break;
	case WifiManager.WIFI_STATE_DISABLING:
		break;
	case WifiManager.WIFI_STATE_DISABLED:
		LogUtil.e(TAG, "wifi disabled");
		break;
	default:
		break;
	}
}
 
Example 7
Source File: WifiStateChangeReceiver.java    From Smartlab with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {

	abortBroadcast();
	
	WifiManager wifiManager = (WifiManager) context
			.getSystemService(Context.WIFI_SERVICE);
	switch (wifiManager.getWifiState()) {
	case WifiManager.WIFI_STATE_DISABLED:
		Toast.makeText(context, "WIFI_STATE_DISABLED", Toast.LENGTH_LONG)
				.show();
		break;
	case WifiManager.WIFI_STATE_ENABLED:
		Toast.makeText(context, "WIFI_STATE_ENABLED", Toast.LENGTH_LONG)
				.show();
		break;
	case WifiManager.WIFI_STATE_DISABLING:
		Toast.makeText(context, "WIFI_STATE_DISABLING", Toast.LENGTH_LONG)
				.show();
		break;
	case WifiManager.WIFI_STATE_ENABLING:
		Toast.makeText(context, "WIFI_STATE_ENABLING", Toast.LENGTH_LONG)
				.show();
		break;
	case WifiManager.WIFI_STATE_UNKNOWN:
		Toast.makeText(context, "WIFI_STATE_UNKNOWN", Toast.LENGTH_LONG)
				.show();
		break;
	}
}
 
Example 8
Source File: QuickWifiHotUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    if (isStop) return;
    // 如果属于需要销毁, 则全部不处理
    if (operate != null && operate.isFinishing()) {
        isStop = true;
        isCheck = false;
        isThreadCheckHot = false;
        return;
    }

    // 是否延时检查
    boolean isPostDelayed = false;
    // 获取 Wifi 连接状态
    switch (wifiUtils.getWifiState()) {
        case WifiManager.WIFI_STATE_ENABLED: // 已打开
        case WifiManager.WIFI_STATE_ENABLING: // 正在打开
            // case WifiManager.WIFI_STATE_UNKNOWN: // 未知
            isPostDelayed = true;
            DevLogger.dTag(TAG, "Wifi 已打开、正在打开");
            wifiUtils.closeWifi(); // 关闭 Wifi
            break;
        case WifiManager.WIFI_STATE_DISABLED: // 已关闭
            isPostDelayed = false;
            DevLogger.dTag(TAG, "Wifi 已关闭");
            break;
        case WifiManager.WIFI_STATE_DISABLING: // 正在关闭
            isPostDelayed = true;
            DevLogger.dTag(TAG, "Wifi 正在关闭");
            break;
    }
    // 判断是否延时 0.4 秒进行开启热点
    if (isPostDelayed) {
        // 删除上一个任务, 并且重新绑定任务
        hotHandler.removeCallbacks(closeWifiThread);
        hotHandler.postDelayed(closeWifiThread, 400);
    } else { // 开启热点
        hotHandler.sendEmptyMessage(CLOSE_WIFI_SUCCESS);
    }
}
 
Example 9
Source File: WifiStateChangeService.java    From fdroidclient with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onHandleIntent(Intent intent) {
    android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_LOWEST);
    if (intent == null) {
        Utils.debugLog(TAG, "received null Intent, ignoring");
        return;
    }
    Utils.debugLog(TAG, "WiFi change service started.");
    NetworkInfo ni = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
    wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
    wifiState = wifiManager.getWifiState();
    Utils.debugLog(TAG, "ni == " + ni + "  wifiState == " + printWifiState(wifiState));
    if (ni == null
            || ni.getState() == NetworkInfo.State.CONNECTED || ni.getState() == NetworkInfo.State.DISCONNECTED) {
        if (previousWifiState != wifiState &&
                (wifiState == WifiManager.WIFI_STATE_ENABLED
                        || wifiState == WifiManager.WIFI_STATE_DISABLING  // might be switching to hotspot
                        || wifiState == WifiManager.WIFI_STATE_DISABLED   // might be hotspot
                        || wifiState == WifiManager.WIFI_STATE_UNKNOWN)) { // might be hotspot
            if (wifiInfoThread != null) {
                wifiInfoThread.interrupt();
            }
            wifiInfoThread = new WifiInfoThread();
            wifiInfoThread.start();
        }

        if (Build.VERSION.SDK_INT < 21 && wifiState == WifiManager.WIFI_STATE_ENABLED) {
            UpdateService.scheduleIfStillOnWifi(this);
        }
    }
}
 
Example 10
Source File: BusinessUtils.java    From freeiot-android with MIT License 5 votes vote down vote up
public static void checkWifi(Context context) {
	WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
	if(wifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED
			|| wifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLING) {
		if (!NetworkUtil.isWifi(context)) {
			WifiConnectUtil.enableAllAps(context);
		}
	}
}
 
Example 11
Source File: WifiHelper.java    From AndroidBasicProject with MIT License 5 votes vote down vote up
/**
 * 启用/禁用 wifi
 * @param enabled
 */
@RequiresPermission(allOf = {
        Manifest.permission.CHANGE_WIFI_STATE,
        Manifest.permission.ACCESS_WIFI_STATE})
public void setEnabled(boolean enabled) {
    if(mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLING ||
            mWifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLING){
        return;
    }
    mWifiManager.setWifiEnabled(enabled);
}
 
Example 12
Source File: NetworkConnectivityManager.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param context
 * @param intent
 * @param action
 */
public void wifiStateChangedAction(Context context, Intent intent, String action)
{
	if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action))
	{
		// 在此监听wifi有无
		int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
		switch (wifiState)
		{
			case WifiManager.WIFI_STATE_DISABLED:
			{
				Toast.makeText(context, "WIFI_STATE_DISABLED", Toast.LENGTH_LONG).show();
				break;
			}
			case WifiManager.WIFI_STATE_DISABLING:
			{
				Toast.makeText(context, "WIFI_STATE_DISABLING", Toast.LENGTH_LONG).show();
				break;
			}
			case WifiManager.WIFI_STATE_ENABLED:
			{
				Toast.makeText(context, "WIFI_STATE_ENABLED", Toast.LENGTH_LONG).show();
				break;
			}
			case WifiManager.WIFI_STATE_ENABLING:
			{
				Toast.makeText(context, "WIFI_STATE_ENABLING", Toast.LENGTH_LONG).show();
				break;
			}
			case WifiManager.WIFI_STATE_UNKNOWN:
			{
				Toast.makeText(context, "WIFI_STATE_UNKNOWN", Toast.LENGTH_LONG).show();
				break;
			}
		}
	}
}
 
Example 13
Source File: WifiHelper.java    From BaseProject with MIT License 5 votes vote down vote up
/**
 * 启用/禁用 wifi
 */
@RequiresPermission(allOf = {Manifest.permission.CHANGE_WIFI_STATE,
                             Manifest.permission.ACCESS_WIFI_STATE})
public void setEnabled(boolean enabled) {
    if (mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLING ||
        mWifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLING) {
        return;
    }
    mWifiManager.setWifiEnabled(enabled);
}
 
Example 14
Source File: WifiReceiver.java    From NetworkGhost with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
            WifiManager.WIFI_STATE_UNKNOWN);
    String wifiStateText = "No State";

    String action = intent.getAction();

    if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
        WifiManager manager = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        NetworkInfo networkInfo = intent
                .getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
        NetworkInfo.State state = networkInfo.getState();

        if (state == NetworkInfo.State.DISCONNECTED) {
            if (manager.isWifiEnabled()) {

                doUpdate(context);
                wifiStateText = "WIFI_STATE_DISCONNECTED";
            }
        }
    }

    switch (wifiState) {
        case WifiManager.WIFI_STATE_DISABLING:
            wifiStateText = "WIFI_STATE_DISABLING";
            break;
        case WifiManager.WIFI_STATE_DISABLED:
            wifiStateText = "WIFI_STATE_DISABLED";
            break;
        case WifiManager.WIFI_STATE_ENABLING:
            wifiStateText = "WIFI_STATE_ENABLING";

            break;
        case WifiManager.WIFI_STATE_ENABLED:
            wifiStateText = "WIFI_STATE_ENABLED";
            if (state == 1) state--;
            else
                doUpdate(context);
            break;
        case WifiManager.WIFI_STATE_UNKNOWN:
            wifiStateText = "WIFI_STATE_UNKNOWN";
            break;
        default:
            break;
    }

    System.out.println("WIFI_recv: " + wifiStateText);
}
 
Example 15
Source File: NetworkConnectChangedReceiver.java    From apollo-DuerOS with Apache License 2.0 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    // Monitor wifi status, have nothing to do with wifi connection
    if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
        int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
        LogUtil.d(TAG, "wifiState:" + wifiState);
        switch (wifiState) {
            case WifiManager.WIFI_STATE_DISABLED:
                break;
            case WifiManager.WIFI_STATE_DISABLING:
                break;
            default:
                break;
        }
    }
    // Monitor the connection status of WiFi, that is whether or not there is an effective wireless routing
    if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
        Parcelable parcelableExtra = intent
                .getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
        if (null != parcelableExtra) {
            // Get the network status of the NetWorkInfo object
            NetworkInfo networkInfo = (NetworkInfo) parcelableExtra;
            // The State object is the state of connection success or not
            NetworkInfo.State state = networkInfo.getState();
            // Determine whether or not the network has been connected
            boolean isConnected = state == NetworkInfo.State.CONNECTED;
            LogUtil.d(TAG, "isConnected:" + isConnected);
        }
    }
    // To monitor the network connection, including wifi and mobile data opening and closing,
    // as well as connection available on the connection had been listening
    if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
        // Get the NetworkInfo object of the network state
        NetworkInfo info = intent
                .getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
        if (info != null) {
            // If the current network connection is successful and the network connection is available
            if (NetworkInfo.State.CONNECTED == info.getState() && info.isAvailable()) {
                if (info.getType() == ConnectivityManager.TYPE_WIFI
                        || info.getType() == ConnectivityManager.TYPE_MOBILE) {
                    LogUtil.i(TAG, getConnectionType(info.getType()) + " connected");
                    // transform to the following module
                    if (mOnNetworkChangeListener != null) {
                        LogUtil.i(TAG, "mOnLocationListener is set");
                        mOnNetworkChangeListener.onNetworkChange();
                    }
                }
            } else {
                LogUtil.i(TAG, getConnectionType(info.getType()) + " disconnected");
                if (mOnNetworkChangeListener != null) {
                    LogUtil.i(TAG, "onShowCompass is set");
                    mOnNetworkChangeListener.onShowCompass();
                }
            }
        }

    }
}
 
Example 16
Source File: NetworkConnectChangedReceiver.java    From apollo-DuerOS with Apache License 2.0 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
        int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
        LogUtil.d(TAG, "wifiState:" + wifiState);
        switch (wifiState) {
            case WifiManager.WIFI_STATE_DISABLED:
                break;
            case WifiManager.WIFI_STATE_DISABLING:
                break;
            default:
                break;
        }
    }
    if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
        Parcelable parcelableExtra = intent
                .getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
        if (null != parcelableExtra) {
            NetworkInfo networkInfo = (NetworkInfo) parcelableExtra;
            NetworkInfo.State state = networkInfo.getState();
            boolean isConnected = state == NetworkInfo.State.CONNECTED;
            LogUtil.d(TAG, "isConnected:" + isConnected);
            // if (isConnected) {
            // } else {
            //
            // }
        }
    }

    if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
        NetworkInfo info = intent
                .getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
        if (info != null) {
            if (NetworkInfo.State.CONNECTED == info.getState() && info.isAvailable()) {
                if (info.getType() == ConnectivityManager.TYPE_WIFI
                        || info.getType() == ConnectivityManager.TYPE_MOBILE) {
                    LogUtil.i(TAG, getConnectionType(info.getType()) + " connected");
                    if (sOnNetworkChangeListener != null) {
                        LogUtil.i(TAG, "mOnLocationListener is set");
                        sOnNetworkChangeListener.onNetworkChange();
                    }
                }
            } else {
                LogUtil.i(TAG, getConnectionType(info.getType()) + " disconnected");
            }
        }

    }
}
 
Example 17
Source File: NetworkConnectChangedReceiver.java    From AndroidDemo with MIT License 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {// 这个监听wifi的打开与关闭,与wifi的连接无关

    if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
        int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
        Log.e(TAG0, "WIFI状态:" + wifiState);
        switch (wifiState) {
            case WifiManager.WIFI_STATE_DISABLED:
                //APP.getInstance().setEnablaWifi(false);
                Log.e(TAG0,"WIFI_STATE_DISABLED" );
                break;
            case WifiManager.WIFI_STATE_DISABLING:
                Log.e(TAG0,"WIFI_STATE_DISABLING" );
                break;
            case WifiManager.WIFI_STATE_ENABLING:
                Log.e(TAG0,"WIFI_STATE_ENABLING" );
                break;
            case WifiManager.WIFI_STATE_ENABLED:
                //APP.getInstance().setEnablaWifi(true);
                Log.e(TAG0,"WIFI_STATE_ENABLED");
                break;
            case WifiManager.WIFI_STATE_UNKNOWN:
                Log.e(TAG0,"WIFI_STATE_UNKNOWN" );
                break;
            default:
                break;
        }
    }
    // 这个监听wifi的连接状态即是否连上了一个有效无线路由,当上边广播的状态是WifiManager
    // .WIFI_STATE_DISABLING,和WIFI_STATE_DISABLED的时候,根本不会接到这个广播。
    // 在上边广播接到广播是WifiManager.WIFI_STATE_ENABLED状态的同时也会接到这个广播,
    // 当然刚打开wifi肯定还没有连接到有效的无线
    if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
        Parcelable parcelableExtra = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
        if (null != parcelableExtra) {
            NetworkInfo networkInfo = (NetworkInfo) parcelableExtra;
            NetworkInfo.State state = networkInfo.getState();
            boolean isConnected = state == NetworkInfo.State.CONNECTED;// 当然,这边可以更精确的确定状态
            Log.e(TAG1, "WIFI连接状态:" + isConnected);
            if (isConnected) {
                //APP.getInstance().setWifi(true);
            } else {
               // APP.getInstance().setWifi(false);
            }
        }
    }
    // 这个监听网络连接的设置,包括wifi和移动数据的打开和关闭。.
    // 最好用的还是这个监听。wifi如果打开,关闭,以及连接上可用的连接都会接到监听。
    // 这个广播的最大弊端是比上边两个广播的反应要慢,如果只是要监听wifi,觉得还是用上边两个配合比较合适。
    if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        Log.i(TAG2, "CONNECTIVITY_ACTION");
        string = "\n您的手机当前网络状态是:\n\n";
        NetworkInfo activeNetwork = manager.getActiveNetworkInfo();
        if (activeNetwork != null) { // connected to the internet
            if (activeNetwork.isConnected()) {
                if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
                    // connected to wifi
                    string += "当前WiFi连接可用 ";
                } else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
                    // connected to the mobile provider's data plan
                    string += "当前移动网络连接可用 ";
                }
            } else {
                string += "当前没有网络连接,请确保你已经打开网络 ";
            }

            string +=   "\n类型名:"        + activeNetwork.getTypeName()+
                        "\n子类型名:"       + activeNetwork.getSubtypeName()+
                        "\n状态:"           + activeNetwork.getState()+
                        "\n详细状态:"       + activeNetwork.getDetailedState().name()+
                        "\n额外状态:"       + activeNetwork.getExtraInfo()+
                        "\n类型:"           + activeNetwork.getType();
        } else {   // not connected to the internet
            string += "当前没有网络连接,请确保你已经打开网络 ";
        }
        Log.e("String:",string);
        brInteraction.setText(string);

    }

}