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.telephony.TelephonyManager;

public class Main {
    private static Context mAppContext = null;

    public static int getMobileNetworkType() {
        if (mAppContext == null)
            return -1;
        TelephonyManager cm = (TelephonyManager) mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
        if (cm == null)
            return -1;
        return cm.getNetworkType();
    }
}