Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static String getNetworkType(ConnectivityManager connManager) {

        NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
        String networkType = null;
        if (networkInfo == null) {
            networkType = "not connect";
        } else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
            networkType = "wifi";
        } else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
            networkType = "mobile";
        }
        return networkType;
    }
}