get NetWork Type - Android android.net

Android examples for android.net:NetworkInfo

Description

get NetWork Type

Demo Code

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {

  public static String getNetWorkType(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo ni = cm.getActiveNetworkInfo();
    return ni.getTypeName();
  }//  ww w .  j  a  va 2s .  c  o m

}

Related Tutorials