Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.net.NetworkInfo.State;

import android.content.Context;

import android.net.ConnectivityManager;

public class Main {
    public static boolean check3GNetworkInfo(Context context) {
        try {
            ConnectivityManager conMan = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            //mobile 3G Data Network
            State mobile = conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();

            return (mobile == State.CONNECTED || mobile == State.CONNECTING);
        } catch (Exception e) {
            return false;
        }
    }
}