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


Java WifiManager.WIFI_STATE_DISABLED属性代码示例

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


在下文中一共展示了WifiManager.WIFI_STATE_DISABLED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: handleMessage

@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case WifiManager.WIFI_STATE_ENABLED:
            LogUtils.d("savor:网络变为可用");
            // 为了解决多次重复发送请求利用延时发送方式
            getSmallPlatformUrl();
            isWifi = true;
            break;
        case WifiManager.WIFI_STATE_DISABLED:
            wifi.setVisibility(View.INVISIBLE);
            isWifi = false;
            break;

    }
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:16,代码来源:LinkTvActivity.java

示例4: wifiDisable

@Rpc(description = "Turns off Wi-Fi with a 30s timeout.")
public void wifiDisable() throws InterruptedException, WifiManagerSnippetException {
    if (mWifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLED) {
        return;
    }
    // If Wi-Fi is trying to turn on, wait for that to complete before continuing.
    if (mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLING) {
        if (!Utils.waitUntil(
                () -> mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED,
                TIMEOUT_TOGGLE_STATE)) {
            Log.e(String.format("Wi-Fi failed to stabilize after %ss.", TIMEOUT_TOGGLE_STATE));
        }
    }
    if (!mWifiManager.setWifiEnabled(false)) {
        throw new WifiManagerSnippetException("Failed to initiate disabling Wi-Fi.");
    }
    if (!Utils.waitUntil(
            () -> mWifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLED,
            TIMEOUT_TOGGLE_STATE)) {
        throw new WifiManagerSnippetException(
                String.format(
                        "Failed to disable Wi-Fi after %ss, timeout!", TIMEOUT_TOGGLE_STATE));
    }
}
 
开发者ID:google,项目名称:mobly-bundled-snippets,代码行数:24,代码来源:WifiManagerSnippet.java

示例5: 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

示例6: 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

示例7: handleMessage

@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case SENSOR_SHAKE:
            exitGameDelayed();
            playHammerAnimation();
            break;
        case EXIT_PRO:
            finish();
            break;
        case WifiManager.WIFI_STATE_ENABLED:
            break;
        case WifiManager.WIFI_STATE_DISABLED:
            mNetWorkSettingsDialog = new CommonDialog(GameActivity.this,"请连接包间wifi","连接后可查看当前酒楼是否有优惠活动"
                    , new CommonDialog.OnConfirmListener() {
                @Override
                public void onConfirm() {
                    Intent intent = new Intent();
                    intent.setAction("android.net.wifi.PICK_WIFI_NETWORK");
                    startActivity(intent);
                    finish();
                }
            }, new CommonDialog.OnCancelListener() {
                @Override
                public void onCancel() {
                    finish();
                }
            },"去连接");
            mNetWorkSettingsDialog.show();
            break;
    }
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:32,代码来源:GameActivity.java

示例8: onReceive

@Override
    public void onReceive(Context context, Intent intent) {
        //wifi更换时判断目标是不是学校wifi,不是的话就停掉
        if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
            NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
            if (info.getState().equals(NetworkInfo.State.CONNECTED)) {  //连上wifi

                WifiUtils wifiUtils = new WifiUtils(context);
                boolean isSchoolWifi = WifiUtils.currentIsSchoolWifi(wifiUtils);
                if(!isSchoolWifi){
                    performMsgCall("wifi切换,已退出登陆");
                    cancelNotification();
                    stopSelf(); //停止service
                    return;
                }
            }
        }
        //wifi关闭就直接停掉
        if (intent.getAction().equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
            int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED);
            if (wifiState == WifiManager.WIFI_STATE_DISABLED) {
                performMsgCall("wifi已关闭,自动退出登陆");
                cancelNotification();
                stopSelf(); //停止service
            }
//            if (wifistate == WifiManager.WIFI_STATE_ENABLED) WIFI开启
        }
    }
 
开发者ID:wintercoder,项目名称:Gdufe-Drcom-Android,代码行数:28,代码来源:DrcomService.java

示例9: 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

示例10: onReceive

@Override
    public void onReceive(Context context, Intent intent) {
        //wifi更换时判断目标是不是学校wifi,不是的话就停掉
        if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
            NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
            if (info.getState().equals(NetworkInfo.State.CONNECTED)) {  //连上wifi

                WifiUtils wifiUtils = new WifiUtils(context);
                boolean isSchoolWifi = DrcomActivity.currentIsSchoolWifi(wifiUtils);
                if(!isSchoolWifi){
                    performMsgCall("wifi切换,已退出登陆");
                    cancelNotification();
                    stopSelf(); //停止service
                    return;
                }
            }
        }
        //wifi关闭就直接停掉
        if (intent.getAction().equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
            int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED);
            if (wifiState == WifiManager.WIFI_STATE_DISABLED) {
                performMsgCall("wifi已关闭,自动退出登陆");
                cancelNotification();
                stopSelf(); //停止service
            }
//            if (wifistate == WifiManager.WIFI_STATE_ENABLED) WIFI开启
        }
    }
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:28,代码来源:DrcomService.java

示例11: 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

示例12: 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

示例13: handleMessage

@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case CLOSE_SSDP_SERVICE:
            LogUtils.d("savor:ssdp 搜索10秒,关闭ssdp服务");
            Intent ssdpIntent = new Intent(mContext, SSDPService.class);
            mContext.stopService(ssdpIntent);
            break;
        case SAVE_BOX_INFO:
            Object obj = msg.obj;
            if(obj instanceof TvBoxInfo) {
                TvBoxInfo tvBoxInfo = (TvBoxInfo) obj;
                mSession.setTvBoxUrl(tvBoxInfo);
                mBindTvView.initBindcodeResult();
            }
            break;
        case SCAN_QR:
            LogUtils.d("二维码结果:" + msg.obj);
            if (TextUtils.isEmpty(msg.obj + "")) {
                mViewCallBack.showToast("无效的数字");
                return;
            }
            // 绑定tv
            mSession.setTVBoxUrl(msg.obj + "");
            mBindTvView.initBindcodeResult();
            break;
        case START_LINKTV:
            if(mBindTvView!=null) {
                mBindTvView.closeQrcodeDialog();
                String topNameActivity = getTopActivityName(mContext);
                if(!topNameActivity.equals(LinkTvActivity.class.getClass().getName())){
                    mBindTvView.startLinkTv();
                }
            }
        case CLOSE_DIALOG:
            if(mBindTvView!=null)
                mBindTvView.closeQrcodeDialog();
            break;
        case CALL_QRCODE:

            break;
        case CALL_CODE_ERRO:
            mViewCallBack.showToast("呼出二维码网络超时");
            break;
        case WifiManager.WIFI_STATE_ENABLED:
            LogUtils.d("savor:网络变为可用");
            // 为了解决多次重复发送请求利用延时发送方式
            getSmallPlatformUrl(true);
            break;
        case WifiManager.WIFI_STATE_DISABLED:
            LogUtils.d("savor:hotel 网络不可用重置酒店id为0");
            mSession.resetPlatform();
            mSession.setHotelid(0);
            mSenseView.hideProjection();
            stopProAndLink();
            break;
        case CHECK_PLATFORM:
            getSmallPlatformUrl(false);
            break;
        case GET_SMALL_FLATFORM:
            getSmallPlatformUrl(false);
            break;
        case REMOVE_QRCODE:
            mSession.setQrcode(null);
            break;
        case REMOVE_BOX_INFO:
            mSession.setTvBoxUrl(null);
            break;
    }
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:70,代码来源:BindTvPresenter.java

示例14: 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

示例15: 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_DISABLED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。