Example usage for android.telecom TelecomManager handleMmi

List of usage examples for android.telecom TelecomManager handleMmi

Introduction

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

Prototype

@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean handleMmi(String dialString, PhoneAccountHandle accountHandle) 

Source Link

Document

Processes the specified dial string as an MMI code.

Usage

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

/**
 * Processes the specified dial string as an MMI code.
 * MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#".
 * Some of these sequences launch special behavior through handled by Telephony.
 *
 * @param telecomManager The {@link TelecomManager} object to use for handling MMI.
 * @param dialString The digits to dial.
 * @return {@code true} if the digits were processed as an MMI code, {@code false} otherwise.
 *///w  w w.  ja  va 2 s  . c o  m
public static boolean handleMmi(@Nullable TelecomManager telecomManager, @Nullable String dialString,
        @Nullable PhoneAccountHandle accountHandle) {
    if (telecomManager == null || TextUtils.isEmpty(dialString)) {
        return false;
    }
    if (CompatUtils.isMarshmallowCompatible()) {
        return telecomManager.handleMmi(dialString, accountHandle);
    }

    Object handleMmiResult = CompatUtils.invokeMethod(telecomManager, "handleMmi",
            new Class<?>[] { PhoneAccountHandle.class, String.class },
            new Object[] { accountHandle, dialString });
    if (handleMmiResult != null) {
        return (boolean) handleMmiResult;
    }

    return telecomManager.handleMmi(dialString);
}