Example usage for android.telecom TelecomManager placeCall

List of usage examples for android.telecom TelecomManager placeCall

Introduction

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

Prototype

@RequiresPermission(anyOf = { android.Manifest.permission.CALL_PHONE,
        android.Manifest.permission.MANAGE_OWN_CALLS })
public void placeCall(Uri address, Bundle extras) 

Source Link

Document

Places a new outgoing call to the provided address using the system telecom service with the specified extras.

Usage

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

/**
 * Places a new outgoing call to the provided address using the system telecom service with
 * the specified intent./*from   w  ww  .java2 s  .c o  m*/
 *
 * @param activity {@link Activity} used to start another activity for the given intent
 * @param telecomManager the {@link TelecomManager} used to place a call, if possible
 * @param intent the intent for the call
 */
public static void placeCall(@Nullable Activity activity, @Nullable TelecomManager telecomManager,
        @Nullable Intent intent) {
    if (activity == null || telecomManager == null || intent == null) {
        return;
    }
    if (CompatUtils.isMarshmallowCompatible()) {
        if (ActivityCompat.checkSelfPermission(activity,
                Manifest.permission.CALL_PHONE) != 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;
        }
        telecomManager.placeCall(intent.getData(), intent.getExtras());
        return;
    }
    activity.startActivityForResult(intent, 0);
}