import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class NetWork {
public static boolean getNet(Context context){
boolean a=false;
ConnectivityManager service = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = service.getActiveNetworkInfo();
if (networkInfo != null) {
a = networkInfo.isAvailable();
}
return a;
};
}
获取网络状态(有网--无网)
猜你喜欢
转载自blog.csdn.net/qq_41423726/article/details/84671388
今日推荐
周排行