List of usage examples for android.telecom TelecomManager getLine1Number
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public String getLine1Number(PhoneAccountHandle accountHandle)
From source file:com.mobileglobe.android.customdialer.common.compat.telecom.TelecomManagerCompat.java
/** * Return the line 1 phone number for given phone account. * * @param telecomManager the {@link TelecomManager} to use in the event that * {@link TelecomManager#getLine1Number(PhoneAccountHandle)} is available * @param telephonyManager the {@link TelephonyManager} to use if TelecomManager#getLine1Number * is unavailable/*from w w w . ja v a2s . c o m*/ * @param phoneAccountHandle the phoneAccountHandle upon which to check the line one number * @return the line one number */ @Nullable public static String getLine1Number(@Nullable TelecomManager telecomManager, @Nullable TelephonyManager telephonyManager, @Nullable PhoneAccountHandle phoneAccountHandle) { if (telecomManager != null && CompatUtils.isMarshmallowCompatible()) { if (ActivityCompat.checkSelfPermission(DialerApplication.getContext(), Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return null; } return telecomManager.getLine1Number(phoneAccountHandle); } if (telephonyManager != null) { return telephonyManager.getLine1Number(); } return null; }