我的应用程序生成如下调用(意图从服务发送):
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + getPhoneNumber());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | intent.FLAG_ACTIVITY_MULTIPLE_TASK);
getContext().startActivity(intent);
它具有以下权限:
<uses-permission android:name="android.permission.CALL_PHONE"/>
它在大多数设备上运行良好,但仅限于某些设备(三星S6,LG - 主要是棒棒糖),它有时会导致呼叫立即终止(并非总是在约30-40%的呼叫中)。
日志显示电信经理神秘地决定断开呼叫:
09-30 09:23:01.731 3565-3565/? I/Telecom﹕ : Delayed disconnection of call: [929220936, CONNECTING, null, ***-***-****,
0, childs(0), has_parent(false), [[Capabilities:]]
有什么想法吗?
答案 0 :(得分:0)
要打开拨号器应用程序(用户必须按拨号程序应用程序内的呼叫按钮;无需其他权限),请使用:
String number = "9999999999";
Uri call = Uri.parse("tel:" + number);
Intent surf = new Intent(Intent.ACTION_DIAL, call);
startActivity(surf);
要打开拨号器应用并自动拨打电话(需要android.permission.CALL_PHONE),请使用:
String number = "9999999999";
Uri call = Uri.parse("tel:" + number);
Intent surf = new Intent(Intent.ACTION_CALL, call);
startActivity(surf);
答案 1 :(得分:0)
您是否在BroadcastReceiver.onReceive内启动了呼叫? 我遇到了同样的问题,似乎当接收器终止时,它会用它来取消呼叫...... 这对我有用:
Intent callIntent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:" + phone));
callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(callIntent);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}