android:用代码设置双卡手机 默认卡2拨打电话

qq_20146753 2016-02-04 03:16:54
android:用代码设置双卡手机 默认卡2拨打电话?

在app中有个设置,是用卡1或卡2打电话,这个程序肿么写了,找了好久找到呀。

或给个方向也行。
...全文
1478 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wushunjun111 2021-07-12
  • 打赏
  • 举报
回复

1

0o王者X风范o0 2016-12-08
  • 打赏
  • 举报
回复 1
public static boolean isMultiSim(Context context){ boolean result = false; TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); if(telecomManager != null){ List<PhoneAccountHandle> phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts(); result = phoneAccountHandleList.size() >= 2; } return result; } 这个用于获取sim数量 public static void call(Context context, int id, String telNum){ TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); if(telecomManager != null){ List<PhoneAccountHandle> phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + telNum)); intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandleList.get(id)); context.startActivity(intent); } } 用指定sim卡拨号 添加了一个携带值 phoneAccountHandleList.get(id) id为0即为卡1 ,1即为卡二 希望对你有帮助 所有的选卡外呼都是在TelephonyManager和TelecomManager这两个类里面找,这是Android 原生的,从5.1版本开始原生就支持双卡拨电话了自己多看看api

80,469

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧