All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yy.androidlib.util.sdk.PhoneUtil Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package com.yy.androidlib.util.sdk;

import android.content.Context;
import android.telephony.TelephonyManager;

public class PhoneUtil {

    public static String getPhoneNumber(Context context) {
        try {
            TelephonyManager tMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            String line1Number = tMgr.getLine1Number();
            if (line1Number == null) {
                line1Number = "";
            } else if (line1Number.startsWith("+86")) {
                line1Number = line1Number.substring(3, line1Number.length());
            }
            return line1Number;
        } catch (Exception e) {
            return "";
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy