get Phone Number - Android android.telephony

Android examples for android.telephony:TelephonyManager

Description

get Phone Number

Demo Code


//package com.java2s;

import android.content.Context;

import android.telephony.TelephonyManager;

public class Main {
    public static String getPhoneNumber(Context context) {
        TelephonyManager telephonyManager = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        String phoneNumber = telephonyManager.getLine1Number();
        return phoneNumber;
    }//w  w w  .j  ava2 s .  c  om
}

Related Tutorials