Example usage for android.telephony TelephonyManager getLine1Number

List of usage examples for android.telephony TelephonyManager getLine1Number

Introduction

In this page you can find the example usage for android.telephony TelephonyManager getLine1Number.

Prototype

@SuppressAutoDoc 
@RequiresPermission(anyOf = { android.Manifest.permission.READ_PHONE_STATE,
        android.Manifest.permission.READ_SMS, android.Manifest.permission.READ_PHONE_NUMBERS })
public String getLine1Number() 

Source Link

Document

Returns the phone number string for line 1, for example, the MSISDN for a GSM phone.

Usage

From source file:Main.java

public static String getUserPhone(Context context) {
    TelephonyManager telemamanger = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return telemamanger.getLine1Number();
}

From source file:Main.java

public static String getPhoneNumber(Context ctx) {
    TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getLine1Number();
}

From source file:Main.java

public static String getMyPhoneNumber(Context context) {
    TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return mTelephonyMgr.getLine1Number();
}

From source file:Main.java

public static String getCurrentPhoneNumber(Context context) {
    TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return mTelephonyMgr.getLine1Number();
}

From source file:Main.java

public static String getPhone(Activity context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String phoneId = tm.getLine1Number();
    return phoneId;
}

From source file:Main.java

private static String getNumber(Context ctx) {
    TelephonyManager tMgr = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    return tMgr.getLine1Number();
}

From source file:Main.java

public static String getPhoneNumber(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getLine1Number();
}

From source file:Main.java

/**
 * To some SIM card, can not retrieve the phone number
 * @param context/*from   w w w.  j a  v a2 s  .  c om*/
 * @return
 */
public static String getPhoneNumber(Context context) {
    TelephonyManager telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return telManager.getLine1Number();
}

From source file:Main.java

public static String getPhoneNumber(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyManager.getLine1Number();
}

From source file:Main.java

/**
 * get phone number./* w w w.j  av  a2s  . c  o  m*/
 * 
 * @return phone number.
 */
public static String getTelePhoneNumber(Context context) {
    String phoneNumber = "";
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    phoneNumber = tm.getLine1Number();
    return phoneNumber;
}