Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

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

public class Main {

    public static String getExtraInfo(Context context) {
        ConnectivityManager connectivity = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo nwInfo = connectivity.getActiveNetworkInfo();
        if (nwInfo == null) {
            return null;
        }
        String extraInfo = nwInfo.getExtraInfo();
        String typeName = nwInfo.getTypeName();
        if (typeName != null && typeName.equalsIgnoreCase("WIFI")) {
            return typeName;
        }
        return extraInfo;
    }
}