Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.annotation.SuppressLint;

import android.content.Context;

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

public class Main {

    @SuppressLint("DefaultLocale")
    public static String getAPNTypeString(Context context) {
        String netType = "";
        ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

        if (networkInfo != null) {
            int nType = networkInfo.getType();
            if (nType == ConnectivityManager.TYPE_MOBILE) {
                String eInfo = networkInfo.getExtraInfo();
                if (eInfo != null) {
                    netType = eInfo.toLowerCase();

                }
            } else if (nType == ConnectivityManager.TYPE_WIFI) {
                netType = "wifi";
            }
        }

        return netType;
    }
}