Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

import android.telephony.TelephonyManager;

public class Main {
    /**
     * Get phone service provider
     *
     * @param context Context
     * @return 10086 10010 10000
     */
    public static String getPhoneServiceProvider(Context context) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String id = tm.getSubscriberId();
        if (id == null) {
            return null;
        }
        if (id.startsWith("46000") || id.startsWith("46002")) {
            return "10086";
        }
        if (id.startsWith("46001")) {
            return "10010";
        }
        if (id.startsWith("46003")) {
            return "10000";
        }
        return null;
    }
}