public static void network(Context context)
{
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = connectivityManager.getActiveNetworkInfo();
if (info.getType() == ConnectivityManager.TYPE_ETHERNET)
{
}
else if (info.getType() == ConnectivityManager.TYPE_WIFI)
{
}
else if (info.getType() == ConnectivityManager.TYPE_MOBILE)
{
}
}
本文摘自 :https://blog.51cto.com/u