Intent intent = new CallIntentBuilder(number)

//35.找到了吧,最初的构造数据是number
//35.回到最初的起点
final Intent intent = new CallIntentBuilder(number).
        setCallInitiationType(LogState.INITIATION_DIALPAD)
        .build();

IntentUtil.CallIntentBuilder

public CallIntentBuilder(String number) {
    this(CallUtil.getCallUri(number));
}              

public CallIntentBuilder(Uri uri) {
    mUri = uri;
}   

public CallIntentBuilder setCallInitiationType(int initiationType) {
    mCallInitiationType = initiationType;
    return this;
}

public Intent build() {
    return getCallIntent(
            mUri,
            mPhoneAccountHandle,
            mIsVideoCall ? VideoProfile.STATE_BIDIRECTIONAL : VideoProfile.STATE_AUDIO_ONLY,
            mCallInitiationType);
}

/**
 * Create a call intent that can be used to place a call.
 * 构建intent,uri目标号码,
 * @param uri Address to place the call to.
 * @param accountHandle {@link PhoneAccountHandle} to place the call with.此处为空
 * @param videoState Initial video state of the call.好像是是否是video ?audio only
 * 初始化电话的类型,应该是有系统phone拨号和其他调用拨号之类的区分
 * @param callIntiationType The UI affordance the call was initiated by.
 * @return Call intent with provided extras and data.
 */
public static Intent getCallIntent(
        Uri uri, PhoneAccountHandle accountHandle, int videoState, int callIntiationType) {
    //String CALL_ACTION = Intent.ACTION_CALL;
    final Intent intent = new Intent(CALL_ACTION, uri);
    intent.putExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, videoState);

    final Bundle b = new Bundle();
    b.putInt(EXTRA_CALL_INITIATION_TYPE, callIntiationType);
    intent.putExtra(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, b);

    if (accountHandle != null) {
        intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle);
    }

    return intent;
}       

CallUtil

public static Uri getCallUri(String number) {
    //
    if (PhoneNumberHelper.isUriNumber(number)) {
        //String SCHEME_SIP = "sip";    
         return Uri.fromParts(PhoneAccount.SCHEME_SIP, number, null);
    }
    return Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
}

PhoneNumberHelper

public static boolean isUriNumber(String number) {
    // Note we allow either "@" or "%40" to indicate a URI, in case
    // the passed-in string is URI-escaped.  (Neither "@" nor "%40"
    // will ever be found in a legal PSTN number.)
    return number != null && (number.contains("@") || number.contains("%40"));
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值