当前位置: 首页>>代码示例>>Java>>正文


Java WifiManager.WIFI_STATE_DISABLING属性代码示例

本文整理汇总了Java中android.net.wifi.WifiManager.WIFI_STATE_DISABLING属性的典型用法代码示例。如果您正苦于以下问题:Java WifiManager.WIFI_STATE_DISABLING属性的具体用法?Java WifiManager.WIFI_STATE_DISABLING怎么用?Java WifiManager.WIFI_STATE_DISABLING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.net.wifi.WifiManager的用法示例。


在下文中一共展示了WifiManager.WIFI_STATE_DISABLING属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onReceive

@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;
    }
}
 
开发者ID:ThanosFisherman,项目名称:WifiUtils,代码行数:18,代码来源:WifiStateReceiver.java

示例2: onHandleIntent

@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, clearing info about wifi state until we have figured it out again.");
    NetworkInfo ni = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
    wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
    int wifiState = wifiManager.getWifiState();
    if (ni == null || ni.isConnected()) {
        Utils.debugLog(TAG, "ni == " + ni + "  wifiState == " + printWifiState(wifiState));
        if (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();
        }
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:25,代码来源:WifiStateChangeService.java

示例3: wifiEnable

@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));
    }
}
 
开发者ID:google,项目名称:mobly-bundled-snippets,代码行数:24,代码来源:WifiManagerSnippet.java

示例4: onReceive

@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;
	}
}
 
开发者ID:leobert-lan,项目名称:UiLib,代码行数:22,代码来源:DLNAService.java

示例5: printWifiState

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";
    }
    return null;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:15,代码来源:WifiStateChangeService.java

示例6: updateWiFiState

private void updateWiFiState(int wifiState) {

		int state;
		int actionState;
		switch (wifiState) {
		case WifiManager.WIFI_STATE_DISABLING:
			state = R.string.txt_status_turning_off;
			actionState = STATE_INPROCESS;
			break;

		case WifiManager.WIFI_STATE_DISABLED:
			state = R.string.txt_status_turned_off;
			actionState = STATE_DONE;
			break;

		case WifiManager.WIFI_STATE_ENABLING:
			state = R.string.txt_status_turning_on;
			actionState = STATE_INPROCESS;
			break;

		case WifiManager.WIFI_STATE_ENABLED:
			state = R.string.txt_status_turned_on;
			actionState = STATE_DONE;
			break;

		default:
			state = R.string.txt_status_unknown;
			actionState = STATE_DONE;
			break;
		}

		String stateText = mActivity.getString(state);
		setActionState(actionState);

		// update description
		Setting setting = mSetting;
		setting.descr = stateText;
		setting.checked = wifiState == WifiManager.WIFI_STATE_ENABLED || wifiState == WifiManager.WIFI_STATE_DISABLING;
		setting.updateView();
	}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:40,代码来源:WiFiSettingHandler.java

示例7: onReceive

@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(TAG, "wifiState" + wifiState);
        switch (wifiState) {
            case WifiManager.WIFI_STATE_DISABLED:
                Log.d(TAG, "onReceive: WIFI_STATE_DISABLED");
                break;
            case WifiManager.WIFI_STATE_DISABLING:
                break;
            case WifiManager.WIFI_STATE_ENABLING:
                break;
            case WifiManager.WIFI_STATE_ENABLED:
                Log.d(TAG, "onReceive: WIFI_STATE_ENABLED");
                break;
            case WifiManager.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 == State.CONNECTED;// 当然,这边可以更精确的确定状态
            Log.e(TAG, "isConnected" + isConnected);
            if (isConnected) {
            } else {
            }
        }
    }

    // 这个监听网络连接的设置,包括wifi和移动数据的打开和关闭。.
    // 最好用的还是这个监听。wifi如果打开,关闭,以及连接上可用的连接都会接到监听。见log
    // 这个广播的最大弊端是比上边两个广播的反应要慢,如果只是要监听wifi,我觉得还是用上边两个配合比较合适
    if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
        ConnectivityManager manager = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        Log.i(TAG, "CONNECTIVITY_ACTION");

        NetworkInfo activeNetwork = manager.getActiveNetworkInfo();
        if (activeNetwork != null) { // connected to the internet
            if (activeNetwork.isConnected()) {
                if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
                    // connected to wifi
                    Log.e(TAG, "当前WiFi连接可用 ");
                } else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
                    // connected to the mobile provider's data plan
                    Log.e(TAG, "当前移动网络连接可用 ");
                }
            } else {
                Log.e(TAG, "当前没有网络连接,请确保你已经打开网络 ");
            }


            Log.e(TAG, "info.getTypeName()" + activeNetwork.getTypeName());
            Log.e(TAG, "getSubtypeName()" + activeNetwork.getSubtypeName());
            Log.e(TAG, "getState()" + activeNetwork.getState());
            Log.e(TAG, "getDetailedState()"+ activeNetwork.getDetailedState().name());
            Log.e(TAG, "getDetailedState()" + activeNetwork.getExtraInfo());
            Log.e(TAG, "getType()" + activeNetwork.getType());
        } else {   // not connected to the internet
            Log.e(TAG, "当前没有网络连接,请确保你已经打开网络 ");
        }
    }
}
 
开发者ID:fendoudebb,项目名称:PlayAndroid,代码行数:75,代码来源:NetworkChangeReceiver.java

示例8: wifiStateChangedAction

/**
 * 
 * @param context
 * @param intent
 * @param action
 */
public static 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;
			}
		}
	}
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:42,代码来源:NetConnectivity.java

示例9: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
        //获取当前的wifi状态int类型数据
        int mWifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
        switch (mWifiState) {
            case WifiManager.WIFI_STATE_ENABLED:
                //已打开
                getWifiList();
                break;
            case WifiManager.WIFI_STATE_ENABLING:
                //打开中
                break;
            case WifiManager.WIFI_STATE_DISABLED:
                //已关闭
                break;
            case WifiManager.WIFI_STATE_DISABLING:
                //关闭中
                break;
            case WifiManager.WIFI_STATE_UNKNOWN:
                //未知
                break;
        }
    } else if (action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)) {
        int linkWifiResult = intent.getIntExtra(WifiManager.EXTRA_SUPPLICANT_ERROR, 123);
        Log.d("XLight", "Get WiFi Result:" + linkWifiResult);
        if (linkWifiResult == WifiManager.ERROR_AUTHENTICATING) {
            ToastUtil.showToast(getApplicationContext(), "密码错误");
        }
    } else if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {//wifi连接上与否
        Log.d("XLight", "网络状态改变");
        NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
        if (info.getState().equals(NetworkInfo.State.DISCONNECTED)) {
            Log.d("XLight", "wifi网络连接断开");
        } else if (info.getState().equals(NetworkInfo.State.CONNECTED)) {
            android.net.wifi.WifiInfo wifiInfo = wifiManager.getConnectionInfo();
            //获取当前wifi名称
            Log.d("XLight", "连接到网络 " + wifiInfo.getSSID());
        }
    }
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:42,代码来源:BindDeviceWiFiActivity.java

示例10: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
        //获取当前的wifi状态int类型数据
        int mWifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
        switch (mWifiState) {
            case WifiManager.WIFI_STATE_ENABLED:
                //已打开
                getWifiList();
                break;
            case WifiManager.WIFI_STATE_ENABLING:
                //打开中
                break;
            case WifiManager.WIFI_STATE_DISABLED:
                //已关闭
                break;
            case WifiManager.WIFI_STATE_DISABLING:
                //关闭中
                break;
            case WifiManager.WIFI_STATE_UNKNOWN:
                //未知
                break;
        }
    } else if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {//wifi连接上与否
        Log.d("XLight", "网络状态改变");
        NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
        if (info.getState().equals(NetworkInfo.State.DISCONNECTED)) {
            Log.d("XLight", "wifi网络连接断开");
        } else if (info.getState().equals(NetworkInfo.State.CONNECTED)) {

            WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
            android.net.wifi.WifiInfo wifiInfo = wifiManager.getConnectionInfo();
            String ssid = wifiInfo.getSSID();
            //获取当前wifi名称
            Log.d("XLight", "连接到网络 " + ssid + ssid.contains("Photon-") + ssid.length());
            if (ssid.contains("Photon-") && ssid.length() >= 11) {
                //连接成功,跳到下一个页面
                Intent intent1 = new Intent(getApplicationContext(), BindDeviceWiFiActivity.class);
                intent1.putExtra("type", type);
                startActivity(intent1);
                finish();
            }
        }
    }
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:46,代码来源:BindDeviceSearchActivity.java


注:本文中的android.net.wifi.WifiManager.WIFI_STATE_DISABLING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。