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


Java State.CONNECTING属性代码示例

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


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

示例1: getNetworkState

public static int getNetworkState(Context context) {
	ConnectivityManager connManager = (ConnectivityManager) context
			.getSystemService(Context.CONNECTIVITY_SERVICE);

	// Wifi
	State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
			.getState();
	if (state == State.CONNECTED || state == State.CONNECTING) {
		return STATE_WIFI;
	}

	// 3G
	state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
			.getState();
	if (state == State.CONNECTED || state == State.CONNECTING) {
		return STATE_MOBILE;
	}
	return STATE_DISCONNECT;
}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:19,代码来源:NetWorkUtil.java

示例2: getNetworkState

public static int getNetworkState(Context context) {
	ConnectivityManager connManager = (ConnectivityManager) context
			.getSystemService(Context.CONNECTIVITY_SERVICE);

	// Wifi
	State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
			.getState();
	if (state == State.CONNECTED || state == State.CONNECTING) {
		return NETWORN_WIFI;
	}

	// 3G
	state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
			.getState();
	if (state == State.CONNECTED || state == State.CONNECTING) {
		return NETWORN_MOBILE;
	}
	return NETWORN_NONE;
}
 
开发者ID:cckevincyh,项目名称:C.,代码行数:19,代码来源:NetUtil.java

示例3: getNetworkType

/**
 * @param context Context
 * @return 1-wifi, 2-3G, 0-无网络连接
 */
public static int getNetworkType(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    State mobileState = connectivityManager.getNetworkInfo(
            ConnectivityManager.TYPE_MOBILE).getState();
    State wifiState = connectivityManager.getNetworkInfo(
            ConnectivityManager.TYPE_WIFI).getState();
    if (wifiState == State.CONNECTED || wifiState == State.CONNECTING) {
        return 1;
    } else if (mobileState == State.CONNECTED
            || mobileState == State.CONNECTING) {
        return 2;
    } else {
        return 0;
    }
}
 
开发者ID:BigAppOS,项目名称:BigApp_WordPress_Android,代码行数:20,代码来源:CommonUtils.java

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

示例5: getNetworkState

/**
    * 获取当前网络状态
    * @param context
    * @return
    */
   public static int getNetworkState(Context context) {
	ConnectivityManager connManager = (ConnectivityManager) context
			.getSystemService(Context.CONNECTIVITY_SERVICE);

	// Wifi
	State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
			.getState();
	if (state == State.CONNECTED || state == State.CONNECTING) {
		return NETWORN_WIFI;
	}

	// 3G
	state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
			.getState();
	if (state == State.CONNECTED || state == State.CONNECTING) {
		return NETWORN_MOBILE;
	}
	return NETWORN_NONE;
}
 
开发者ID:misty-rain,项目名称:smartedu,代码行数:24,代码来源:NetUtility.java

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

示例7: checkNetworkState

/**
 * ���������
 */
private void checkNetworkState() {

	State gprs = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
	State wifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
	// �ж�Ϊgprs״̬
	if (gprs == State.CONNECTED || gprs == State.CONNECTING) {
		tv_network_on.setText("���������ӣ�GPRS");
	}
	// �ж�Ϊwifi״̬
	if (wifi == State.CONNECTED || wifi == State.CONNECTING) {
		tv_network_on.setText("���������ӣ�WIFI");
	}
}
 
开发者ID:REIGE,项目名称:AndroidTest,代码行数:16,代码来源:activity_network.java

示例8: isWifi

public boolean isWifi() {
	// TODO Auto-generated method stub
	if(checkNetwork()){
		State wifi = con.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
		//判断wifi已连接的条件
		if(wifi == State.CONNECTED||wifi==State.CONNECTING){
			return true;
		}
		return false;
	}
	return false;
}
 
开发者ID:Rabbit00,项目名称:MeifuGO,代码行数:12,代码来源:HNetwork.java

示例9: isWiFi

/**
 * 只是判断WIFI
 *
 * @param context 上下文
 * @return 是否打开Wifi
 */
public static boolean isWiFi(Context context) {
    ConnectivityManager manager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    State wifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
            .getState();
    if (wifi == State.CONNECTED || wifi == State.CONNECTING)
        return true;
    return false;

}
 
开发者ID:DIY-green,项目名称:AndroidStudyDemo,代码行数:16,代码来源:NetUtil.java

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

示例11: isNetworkAvailable

/**
 * 网络已经连接,然后去判断是wifi连接还是GPRS连接 设置逻辑调用
 */
private void isNetworkAvailable() {

	State gprs = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
			.getState();
	State wifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
			.getState();
	// GPRS,流量状态下,拷贝数据库
	if (gprs == State.CONNECTED || gprs == State.CONNECTING) {
		Toast.makeText(this, "gprs(流量)状态下,copy初始数据~~", Toast.LENGTH_SHORT)
				.show();
		Boolean copyDatabase = new CopyDbToSdcard(getApplicationContext())
				.copyDatabase();
		copyFileOrLoad(copyDatabase);
	}
	// 判断为wifi状态下才加载地区数据,否则不加载
	if (wifi == State.CONNECTED || wifi == State.CONNECTING) {
		// 没有数据的时候初始化一个dialog做初始化操作用
		dialog = new ProgressDialog(MainActivity.this);
		// 设置进度条风格,风格为圆形,旋转的
		dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
		// 设置ProgressDialog 提示信息
		dialog.setMessage("正在初始化数据,请稍候...");
		// 设置ProgressDialog 标题图标
		// m_pDialog.setIcon(R.drawable.icon);
		// 设置ProgressDialog 的进度条是否不明确
		dialog.setIndeterminate(false);
		// 设置ProgressDialog 是否可以按退回按键取消
		dialog.setCancelable(false);
		dialog.setCanceledOnTouchOutside(false);
		dialog.show();
		Toast.makeText(getApplicationContext(), "Wifi状态下,数据录入准备~请稍等...",
				Toast.LENGTH_LONG).show();
		new GetAreaDataSaveDB(getApplicationContext(),
				MainActivity.this.dialog);
		initLocation();
	}
}
 
开发者ID:PengSen,项目名称:work_sen,代码行数:40,代码来源:MainActivity.java

示例12: isWifiAvailable

private boolean isWifiAvailable() {
	Context context = ZenApplication.getAppContext();
	ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

	State wifi = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
			.getState();
	if(wifi == State.CONNECTED || wifi == State.CONNECTING) {
		System.out.println("wifi available");
		return true;
	}
	return false;
}
 
开发者ID:nihaoyalong,项目名称:zen4android,代码行数:12,代码来源:ZenAdsManager.java

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


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