get First Phone Number - Android android.telephony

Android examples for android.telephony:TelephonyManager

Description

get First Phone Number

Demo Code


//package com.java2s;

import android.content.Context;

import android.telephony.TelephonyManager;

public class Main {
    public static String getFirstPhoneNumber(Context context) {
        if (context == null) {
            return null;
        }/*from  w w w .  ja v a  2 s.  com*/
        TelephonyManager telephonyManager = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        return telephonyManager.getLine1Number();
    }
}

Related Tutorials