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

分类:手机开发| 发布:佚名| 查看: | 发表时间:2015/7/15
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;
}
365据说看到好文章不转的人,服务器容易宕机
原创文章如转载,请注明:转载自郑州网建-前端开发 http://camnpr.com/
本文链接:http://camnpr.com/mobile-dev/2074.html