get Phone Subscriber Id - Android Hardware

Android examples for Hardware:Sim Card

Description

get Phone Subscriber Id

Demo Code


//package com.java2s;
import android.content.Context;
import android.telephony.TelephonyManager;

public class Main {

    public static String getSubscriberId(Context context) {
        TelephonyManager tm = getTelephonyManager(context);
        if (tm != null) {
            return tm.getSubscriberId();
        }/*from  w  w  w . j  av  a  2  s  . c o m*/
        return null;
    }

    private static TelephonyManager getTelephonyManager(Context context) {
        return (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
    }
}

Related Tutorials