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 getcurrentNetworkNoWifi(Context context) {
        String network_type = "UNKNOWN";// maybe usb reverse tethering
        NetworkInfo active_network = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE))
                .getActiveNetworkInfo();
        if (active_network != null && active_network.isConnectedOrConnecting()) {
            network_type = active_network.getSubtypeName();
        }
        return network_type;
    }
}