Returns the SIM serial number - Android Hardware

Android examples for Hardware:Sim Card

Description

Returns the SIM serial number

Demo Code


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

public class Main {
    /**//from w  w w .ja  va2s. co  m
     * Returns the SIM serial number
     * 
     * @param context
     * @return The SIM serial number
     */
    public static String getSimSerialNumber(final Context context) {
        final TelephonyManager tm = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        if (null == tm)
            return null;

        return tm.getSimSerialNumber();
    }
}

Related Tutorials