Example usage for android.telecom TelecomManager getVoiceMailNumber

List of usage examples for android.telecom TelecomManager getVoiceMailNumber

Introduction

In this page you can find the example usage for android.telecom TelecomManager getVoiceMailNumber.

Prototype

@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public String getVoiceMailNumber(PhoneAccountHandle accountHandle) 

Source Link

Document

Return the voicemail number for a given phone account.

Usage

From source file:com.mobileglobe.android.customdialer.common.compat.telecom.TelecomManagerCompat.java

/**
 * Return the voicemail number for a given phone account.
 *
 * @param telecomManager The {@link TelecomManager} object to use for retrieving the voicemail
 * number if accountHandle is specified.
 * @param telephonyManager The {@link TelephonyManager} object to use for retrieving the
 * voicemail number if accountHandle is null.
 * @param accountHandle The handle for the phone account.
 * @return The voicemail number for the phone account, and {@code null} if one has not been
 *         configured.//from   w w  w  . jav  a  2s  .c om
 */
@Nullable
public static String getVoiceMailNumber(@Nullable TelecomManager telecomManager,
        @Nullable TelephonyManager telephonyManager, @Nullable PhoneAccountHandle accountHandle) {
    if (telecomManager != null && (CompatUtils.isMethodAvailable(TELECOM_MANAGER_CLASS, "getVoiceMailNumber",
            PhoneAccountHandle.class))) {
        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.getVoiceMailNumber(accountHandle);
    } else if (telephonyManager != null) {
        return telephonyManager.getVoiceMailNumber();
    }
    return null;
}