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


Java State.DISCONNECTED属性代码示例

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


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

示例1: updateState

void updateState(State state) {
	
	if (state != State.DISCONNECTED) {
		mTryCounter = 0;
	}
	
	Setting s = mSetting; int resId;
	switch (state) {
		case CONNECTED: s.checked = true; s.enabled = true; resId = R.string.txt_net_status_connected; break;
		case CONNECTING: s.checked = false; s.enabled = false; resId = R.string.txt_net_status_connecting; break;
		case DISCONNECTED: s.checked = false; s.enabled = true; resId = R.string.txt_net_status_disconnected; break;
		case DISCONNECTING: s.checked = true; s.enabled = false; resId = R.string.txt_net_status_disconnecting; break;
		default: s.checked = s.enabled = false; resId = R.string.txt_status_unknown; break;
	}
	s.descr = getString(resId);
	s.updateView();
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:17,代码来源:MobileDataSettingHandler2.java

示例2: onReceive

@Override
public void onReceive(final Context c, final Intent i) {
	final String a = i.getAction();
	if (a.equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) && FonManService.isAutoConnectEnabled(c)) {
		FonManService.execute(c, Constants.ACT_CONNECT);
	} else if (a.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
		final NetworkInfo ni = (NetworkInfo) i.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
		if (ni.getType() == ConnectivityManager.TYPE_WIFI) {
			final State s = ni.getState();
			if (s == State.CONNECTED) {
				FonManService.execute(c, Constants.ACT_LOGIN);
			} else if (s == State.DISCONNECTED) {
				FonManService.execute(c, Constants.ACT_CLEANUP);
			}
		}
	}
}
 
开发者ID:rsalvaterra,项目名称:Fon,代码行数:17,代码来源:FonManWifiReceiver.java

示例3: getDataConnectionState

public static int getDataConnectionState(Context context) {
    if (!isSimInstalled(context)) {
        return NETWORK_UTILS_CONNECTION_STATE_DISCONNECTED;
    }

    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    for (NetworkInfo info : manager.getAllNetworkInfo()) {
        if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
            if (info.getState() == State.CONNECTED) {
                return NETWORK_UTILS_CONNECTION_STATE_CONNECTED;
            } else if (info.getState() == State.DISCONNECTED) {
                return NETWORK_UTILS_CONNECTION_STATE_DISCONNECTED;
            } else if (info.getState() == State.CONNECTING) {
                return NETWORK_UTILS_CONNECTION_STATE_CONNECTING;
            } else if (info.getState() == State.DISCONNECTING) {
                return NETWORK_UTILS_CONNECTION_STATE_DISCONNECTED;
            } else if (info.getState() == State.SUSPENDED) {
                return NETWORK_UTILS_CONNECTION_STATE_SUSPENDED;
            } else if (info.getState() == State.UNKNOWN) {
                return NETWORK_UTILS_CONNECTION_STATE_UNKNOWN;
            }
        }
    }

    return NETWORK_UTILS_CONNECTION_STATE_DISCONNECTED;
}
 
开发者ID:ashank,项目名称:Office-365-SDK-for-Android,代码行数:26,代码来源:NetworkUtils.java

示例4: log

private void log(boolean noConnectivity, State affectedState,
		DetailedState detailedState, NetworkInfo mNetworkInfo,
		NetworkInfo mOtherNetworkInfo, String mReason, boolean mIsFailover) {

	// Log
	if (Constants.Debug) {
		//Log.d(TAG, "EXTRA_REASON Flag: " + mReason);
		//Log.d(TAG, "EXTRA_IS_FAILOVER Flag: " + mIsFailover);
		//Log.d(TAG, "EXTRA_NO_CONNECTIVITY Flag: " + noConnectivity);
		// Log.d(TAG, "mNetworkInfo.getState(): "+affectedState);
		// Log.d(TAG,
		// "mNetworkInfo.getDetailedState(): "+detailedState);
		Log.d(TAG, "------ Reciever Called -----------");
		Log.d(TAG, "noConn=" + noConnectivity + ", AffectedState: "
				+ affectedState + ", DetailedState: " + detailedState);
		Log.d(TAG, "mNetworkInfo: " + mNetworkInfo);
		Log.d(TAG, "mOtherNetworkInfo: "
				+ (mOtherNetworkInfo == null ? "[none]"
						: mOtherNetworkInfo));
		State mState = (noConnectivity) ? State.DISCONNECTED
				: State.CONNECTED;
		Log.d(TAG, " mState=" + mState.toString() + ", mReason="
				+ mReason + ", mIsFailover=" + mIsFailover);
	}		
}
 
开发者ID:ET-CS,项目名称:EZ-Wifi-Notification,代码行数:25,代码来源:IntentAnalyzer.java

示例5: onReceive

public void onReceive(Context c, Intent intent) {
	NetworkInfo wifiNetworkInfo = (NetworkInfo) intent
			.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
	Log.v(TAG, "mWifiNetworkInfo: " + wifiNetworkInfo.toString());

	if (wifiNetworkInfo.getState() == State.CONNECTED) {
		log.setText("Connected to: "
				+ wifiManager.getConnectionInfo().getSSID());
		if (wifiManager != null
				&& wifiManager.getConnectionInfo() != null
				&& wifiManager.getConnectionInfo().getSSID() != null
				&& !wifiManager.getConnectionInfo().getSSID()
						.equals(wifiSSID)) {
			Log.v(TAG, wifiManager.getConnectionInfo().getSSID());

			refreshWifi();					
		}
	} else if (wifiNetworkInfo.getState() == State.CONNECTING) {
		log.setText("Connecting...");
	} else if (wifiNetworkInfo.getState() == State.DISCONNECTING) {
		log.setText("Disconnecting...");
	} else if (wifiNetworkInfo.getState() == State.DISCONNECTED) {
		log.setText("Disconnected");
	}

}
 
开发者ID:takyonxxx,项目名称:Gopro-Manager-Android,代码行数:26,代码来源:GoproActivity.java

示例6: onReceive

@Override
public final void onReceive(Context context, Intent intent) {
    ConnectivityManager cm = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo wifiInfo = cm
            .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    NetworkInfo gprsInfo = cm
            .getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
 
    // 判断是否是Connected事件
    boolean wifiConnected = false;
    boolean gprsConnected = false;
    if (wifiInfo != null && wifiInfo.isConnected()) {
        wifiConnected = true;
    }
    if (gprsInfo != null && gprsInfo.isConnected()) {
        gprsConnected = true;
    }
    if (wifiConnected || gprsConnected) {
        onConnected();
        return;
    }
 
    // 判断是否是Disconnected事件,注意:处于中间状态的事件不上报给应用!上报会影响体验
    boolean wifiDisconnected = false;
    boolean gprsDisconnected = false;
    if (wifiInfo == null || wifiInfo != null
            && wifiInfo.getState() == State.DISCONNECTED) {
        wifiDisconnected = true;
    }
    if (gprsInfo == null || gprsInfo != null
            && gprsInfo.getState() == State.DISCONNECTED) {
        gprsDisconnected = true;
    }
    if (wifiDisconnected && gprsDisconnected) {
        onDisconnected();
        return;
    }
}
 
开发者ID:LiuJunb,项目名称:Android-LSS,代码行数:39,代码来源:NetworkUtils.java

示例7: onReceive

@Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (ACTION_HEALTH_CHECK.equals(action)) {//处理心跳
            if (MPush.I.hasStarted()) {
                if (MPush.I.client.isRunning()) {
                    if (MPush.I.client.healthCheck()) {
                        startAlarm(context, delay);
                    }
                }
            }
        } else if (CONNECTIVITY_ACTION.equals(action)) {//处理网络变化
            if (hasNetwork(context)) {
                if (STATE != State.CONNECTED) {
                    STATE = State.CONNECTED;
                    if (MPush.I.hasStarted()) {
                        MPush.I.onNetStateChange(true);

                        //MPush.I.resumePush();
                    } else {
                        MPush.I.checkInit(context).startPush();
                    }
                }
            } else {
                if (STATE != State.DISCONNECTED) {
                    STATE = State.DISCONNECTED;
                    MPush.I.onNetStateChange(false);

                    //MPush.I.pausePush();
                    //cancelAlarm(context);//防止特殊场景下alarm没被取消
                }
            }
        } else if (ACTION_NOTIFY_CANCEL.equals(action)) {//处理通知取消
//            Notifications.I.clean(intent);
        }
        Log.d("MPush", "Receiver");
    }
 
开发者ID:stulip,项目名称:react-native-mpush,代码行数:37,代码来源:MPushReceiver.java

示例8: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (ACTION_HEALTH_CHECK.equals(action)) {//处理心跳
        if (MPush.I.hasStarted()) {
            if (MPush.I.client.isRunning()) {
                if (MPush.I.client.healthCheck()) {
                    startAlarm(context, delay);
                }
            }
        }
    } else if (CONNECTIVITY_ACTION.equals(action)) {//处理网络变化
        if (hasNetwork(context)) {
            if (STATE != State.CONNECTED) {
                STATE = State.CONNECTED;
                if (MPush.I.hasStarted()) {
                    MPush.I.onNetStateChange(true);

                    //MPush.I.resumePush();
                } else {
                    MPush.I.checkInit(context).startPush();
                }
            }
        } else {
            if (STATE != State.DISCONNECTED) {
                STATE = State.DISCONNECTED;
                MPush.I.onNetStateChange(false);

                //MPush.I.pausePush();
                //cancelAlarm(context);//防止特殊场景下alarm没被取消
            }
        }
    } else if (ACTION_NOTIFY_CANCEL.equals(action)) {//处理通知取消
        Notifications.I.clean(intent);
    }
}
 
开发者ID:mpusher,项目名称:mpush-android,代码行数:36,代码来源:MPushReceiver.java

示例9: getWifiStatus

public static String getWifiStatus(Context context) {
	String wifiStatus = "";
	ConnectivityManager conMan = (ConnectivityManager) context
			.getSystemService(Context.CONNECTIVITY_SERVICE);
	State wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
			.getState();

	WifiManager wifiManager = (WifiManager) context
			.getSystemService(Context.WIFI_SERVICE);
	WifiInfo wifiInfo = wifiManager.getConnectionInfo();
	String ssid = wifiInfo.getSSID();

	if (wifi == State.CONNECTED) {
		wifiStatus = "无线网络已连接, " + "SSID: " + ssid;
	} else if (wifi == State.CONNECTING) {
		wifiStatus = "无线网络正在连接, " + "SSID: " + ssid;
	} else if (wifi == State.DISCONNECTED) {
		wifiStatus = "无线网络已断开";
	} else if (wifi == State.DISCONNECTING) {
		wifiStatus = "无线网络正在断开, " + "SSID: " + ssid;
	} else if (wifi == State.SUSPENDED) {
		wifiStatus = "无线网络挂起";
	} else if (wifi == State.UNKNOWN) {
		wifiStatus = "无线网络未连接";
	}
	return wifiStatus;
}
 
开发者ID:leleliu008,项目名称:Newton_for_Android_AS,代码行数:27,代码来源:Helper.java

示例10: onReceive

public void onReceive(Context ctx, Intent intent) {

        if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {// 这个监听wifi的连接状态
            //Log.i("receiver","NETWORK_STATE_CHANGED_ACTION");
            Parcelable parcelableExtra = intent
                    .getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
            if (null != parcelableExtra) {
                NetworkInfo networkInfo = (NetworkInfo) parcelableExtra;
                State state = networkInfo.getState();
                if (state == State.CONNECTED) { // 表示wifi状态改变
                    Log.i("receiver", "wifi状态改变");
                    WifiAdmin wifiAdmin = new WifiAdmin(ctx);
                    String ssidName = wifiAdmin.getSSID();
                    Log.i("receiver connect to:", ssidName);
                    boolean isSaved = SpUtil.getSp(ctx).getBoolean("isSaved",false);
                    // 判断是否连接了DLUT
                    if (isSaved && ssidName.contains(WIFI_SSID) && SpUtil.getLoginState(ctx) == false) {
                        Toast.makeText(ctx,"连接DLUT中...",Toast.LENGTH_SHORT).show();
                        ctx.startService(new Intent(ctx, MyService.class));

                    }
                } else if (state == State.DISCONNECTED) {
                    SpUtil.setLoginState(ctx,false);
                    ctx.sendBroadcast(new Intent(UiReceiver.ACTION_UPDATE_UI));
                }
            }
        }
    }
 
开发者ID:yimun,项目名称:DLUTLogin,代码行数:28,代码来源:WifiReceiver.java

示例11: setNetworkConnection

public void setNetworkConnection(Context context) {
	this.currentContext = context;

	ConnectivityManager connectivityManager = (ConnectivityManager) context
			.getSystemService(Context.CONNECTIVITY_SERVICE);

	NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

	if (networkInfo == null) {
		VoiceApi.makeToastShort(currentContext, "无网络连接");
		return;
	}
	switch (networkInfo.getType()) {
	case ConnectivityManager.TYPE_WIFI:
		VoiceApi.makeToastShort(context, "WIFI Connection");
		break;
	case ConnectivityManager.TYPE_MOBILE:
		VoiceApi.makeToastShort(context, "MOBILE Connection");
		break;
	default:
		VoiceApi.makeToastShort(context, "Unknown Connection");
		break;
	}

	boolean available = networkInfo.isAvailable();
	if (available) {
		VoiceApi.makeToastShort(context,
				"Current Connectivity is Available");
	} else {
		VoiceApi.makeToastShort(context,
				"Current Connectivity is not Available");
	}

	State state = connectivityManager.getNetworkInfo(
			ConnectivityManager.TYPE_MOBILE).getState();
	if (State.CONNECTED == state) {
		VoiceApi.makeToastShort(context, "GPRS Connected");
	} else if (State.CONNECTING == state) {
		VoiceApi.makeToastShort(context, "GPRS Connecting");
	} else if (State.DISCONNECTING == state) {
		VoiceApi.makeToastShort(context, "GPRS Disconnecting");
	} else if (State.DISCONNECTED == state) {
		VoiceApi.makeToastShort(context, "GPRS Disconnected");
	} else {
		VoiceApi.makeToastShort(context, "Other GPRS State");
	}

	state = connectivityManager.getNetworkInfo(
			ConnectivityManager.TYPE_WIFI).getState();
	if (State.CONNECTED == state) {
		VoiceApi.makeToastShort(context, "WIFI Connected");
	} else if (State.CONNECTING == state) {
		VoiceApi.makeToastShort(context, "WIFI Connecting");
	} else if (State.DISCONNECTING == state) {
		VoiceApi.makeToastShort(context, "WIFI Disconnecting");
	} else if (State.DISCONNECTED == state) {
		VoiceApi.makeToastShort(context, "WIFI Disconnected");
	} else {
		VoiceApi.makeToastShort(context, "Other WIFI State");
	}

	context.startActivity(new Intent(
			android.provider.Settings.ACTION_WIRELESS_SETTINGS));
}
 
开发者ID:3c,项目名称:TestRecord,代码行数:64,代码来源:VoiceApi.java

示例12: handleNetworkStateChangedAction

private void handleNetworkStateChangedAction(NetworkInfo networkInfo) {
	Log.i(TAG,
			networkInfo.getState() + " with" + networkInfo.toString());

	if (networkInfo.getState() == State.CONNECTED) {
		final WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
		
		if(wifiInfo!=null && wifiInfo.getSSID()!=null && wifiInfo.getSSID().length()>0){
			String lSSID = wifiInfo.getSSID().replace("\"", "");
			
			mNetworkId = wifiInfo.getNetworkId();
			
			int ipAddress = wifiInfo.getIpAddress();
			
			String ipFormattedAsString = formatIpAddress(ipAddress);
			
			if (lSSID !=null) {
				
				sendConnectionBroadcast(ChaskiConstants.CONNECTED_STATE, lSSID, ipFormattedAsString, null);
				
				
			}
		}
	}
	
	if (networkInfo.getState() == State.DISCONNECTED) {
		
		Log.d(TAG, "disconnected");
		
		sendConnectionBroadcast(ChaskiConstants.DISCONNECTED_STATE, null, null, null);
		
	}
	
}
 
开发者ID:chaski-framework,项目名称:chaski,代码行数:34,代码来源:ChaskiService.java


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