Example usage for android.telephony PhoneNumberUtils isVoiceMailNumber

List of usage examples for android.telephony PhoneNumberUtils isVoiceMailNumber

Introduction

In this page you can find the example usage for android.telephony PhoneNumberUtils isVoiceMailNumber.

Prototype

public static boolean isVoiceMailNumber(String number) 

Source Link

Document

isVoiceMailNumber: checks a given number against the voicemail number provided by the RIL and SIM card.

Usage

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

/**
 * Return whether a given phone number is the configured voicemail number for a
 * particular phone account./*w w w .  j  a  va2 s .  co m*/
 *
 * @param telecomManager the {@link TelecomManager} to use for checking the number.
 * @param accountHandle The handle for the account to check the voicemail number against
 * @param number The number to look up.
 */
public static boolean isVoiceMailNumber(@Nullable TelecomManager telecomManager,
        @Nullable PhoneAccountHandle accountHandle, @Nullable String number) {
    if (telecomManager != null
            && (CompatUtils.isMarshmallowCompatible() || CompatUtils.isMethodAvailable(TELECOM_MANAGER_CLASS,
                    "isVoiceMailNumber", PhoneAccountHandle.class, String.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 false;
        }
        return telecomManager.isVoiceMailNumber(accountHandle, number);
    }

    return PhoneNumberUtils.isVoiceMailNumber(number);
}