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;

import android.util.Log;

public class Main {
    private static final String TAG = "Util";

    public static boolean providersNameIsYidong(Context context) {
        String IMSI = getIMSI(context);
        if (IMSI.startsWith("46000") || IMSI.startsWith("46002")) {
            return true;
        }
        return false;
    }

    public static String getIMSI(Context context) {
        String imsi = "";
        try {
            TelephonyManager phoneManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            imsi = phoneManager.getSubscriberId();
            Log.v(TAG, imsi);
        } catch (Exception e) {
            Log.e(TAG, "getIMSI error!");
            imsi = "";
        }

        if (imsi == null) {
            imsi = "";
        }
        return imsi;
    }
}