package fmh.bwie.com.wifi.utils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class WifiUtils {
public static int getNettype(Context context){
int netType=-1;
ConnectivityManager systemService = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = systemService.getActiveNetworkInfo();
if (networkInfo==null){
return netType;
}
int type = networkInfo.getType();
if (type==ConnectivityManager.TYPE_MOBILE){
netType=2;
}else if (type ==ConnectivityManager.TYPE_WIFI){
netType=1;
}
return netType;
}
}
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class WifiUtils {
public static int getNettype(Context context){
int netType=-1;
ConnectivityManager systemService = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = systemService.getActiveNetworkInfo();
if (networkInfo==null){
return netType;
}
int type = networkInfo.getType();
if (type==ConnectivityManager.TYPE_MOBILE){
netType=2;
}else if (type ==ConnectivityManager.TYPE_WIFI){
netType=1;
}
return netType;
}
}