Android Phone Number Get getMyPhoneNumber(Context ctx)

Here you can find the source of getMyPhoneNumber(Context ctx)

Description

get My Phone Number

Declaration

public static String getMyPhoneNumber(Context ctx) 

Method Source Code

//package com.java2s;

import android.content.Context;

import android.telephony.TelephonyManager;

public class Main {
    public static String getMyPhoneNumber(Context ctx) {

        try {/* ww  w .j a v a  2 s .co m*/
            TelephonyManager mTelephonyMgr;
            mTelephonyMgr = (TelephonyManager) ctx
                    .getSystemService(Context.TELEPHONY_SERVICE);
            return mTelephonyMgr.getLine1Number();
        } catch (Exception e) {
            return "";
        }

    }
}

Related

  1. getPhoneNumber(Context context)
  2. getPlainPhoneNumber(String phoneNumber)
  3. getMy10DigitPhoneNumber(Context ctx)
  4. getPhoneNumber(int contactId)