get Phone Line Number - Android Hardware

Android examples for Hardware:Sim Card

Description

get Phone Line Number

Demo Code


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

public class Main {

    public static String getLine1Number(Context context) {
        TelephonyManager tm = getTelephonyManager(context);
        if (tm != null) {
            return tm.getLine1Number();
        }//from  w  w w  . j  a v a2s.  c om
        return null;
    }

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

Related Tutorials