β

Android(安卓)判断是否联网及判断SDK版本

郑州网建 92 阅读
public static int getSDKVersionNumber() {
		int sdkVersion;
		try {
			sdkVersion = Integer.valueOf(android.os.Build.VERSION.SDK);

		} catch (NumberFormatException e) {

			sdkVersion = 0;
		}
		return sdkVersion;
	}
public static boolean hasInternet(Activity activity) {
		ConnectivityManager manager = (ConnectivityManager) activity
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo info = manager.getActiveNetworkInfo();
		if (info == null || !info.isConnected()) {
			return false;
		}
		if (info.isRoaming()) {
			return true;
		}
		return true;
	}
作者:郑州网建
Good Good Study ,Day Day Up!
原文地址:Android(安卓)判断是否联网及判断SDK版本, 感谢原作者分享。

发表评论