get Network Type Name - Android Network

Android examples for Network:Network Operation

Description

get Network Type Name

Demo Code


//package com.java2s;

import android.content.Context;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public static String getNetworkTypeName(Context context) {
        String netType = "";
        if (context != null) {
            ConnectivityManager cm = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo info = cm.getActiveNetworkInfo();
            if (info != null && info.getExtraInfo() != null) {
                netType = info.getTypeName() + "_"
                        + info.getExtraInfo().replace("\"", "");
            }/* www  . j ava2  s .  c  om*/
        }
        return netType;

    }
}

Related Tutorials