网络判断
程序员文章站
2022-03-04 08:47:56
...
添加权限
Java
package com.exam.pulltrandsql.util;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class NetStateUtils {
public static boolean iscoon(Context context){
boolean bisConnFlag=false;
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = manager.getActiveNetworkInfo();
if(networkInfo!=null){
bisConnFlag = manager.getActiveNetworkInfo().isAvailable();
}
return bisConnFlag;
}
}
上一篇: MySQL复制表结构和表数据