0

我正在尝试在广播事件中拨打电话。此刻我正在从广播接收器的 onreceive() 方法调用另一个活动。在那个活动中我正在使用这个意图

Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel"+num));
     callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     con.startActivity(callIntent);

问题是呼叫在启动后立即断开连接。我正在 Galaxy nexus 4.1.1 上尝试这个,我使用了以下权限:

 <uses-permission android:name="android.permission.CALL_PHONE" />

我是android的初学者,欢迎任何帮助。

当呼叫自动结束时,这会出现在 LogCat 中:

ActivityManager(387): START u0 {act=android.intent.action.CALL dat=tel:xxxxxxxxxxxxx flg=0x10000000 cmp=com.android.phone/.OutgoingCallBroadcaster} from pid 6329

 I/ActivityManager(387): START u0 {act=com.android.phone.SIP_SELECT_PHONE dat=tel:xxxxxxxxxxxxx flg=0x10000000 cmp=com.android.phone/.SipCallOptionHandler (has extras)} from pid 577

D/CallController(577): placeCall()...  intent = Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxxxxx (has extras) }

 I/AudioService(387):  AudioFocus  requestAudioFocus() from AudioFocus_For_Phone_Ring_And_Calls

 E/audio_hw_primary(131): Entering IN_CALL state, in_call=0

 E/audio_hw_primary(131): Opening modem PCMs

 I/LocalDevicePlayback(6366): pause: transient=false, currentPos=-1

D/PhoneUtils(577): placeCall()... number: xxxxxxxxxxxxx, GW: null, emergency? false

4

1 回答 1

0

我在最后测试了您的代码,经过一点改动后它在我的最后运行良好。我认为问题在于您需要:tel. 以下是更正后的代码..

String url = "tel:123456789";
            Intent dialIntent = new Intent(Intent.ACTION_CALL, Uri.parse(url));
            dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(dialIntent);
于 2012-11-29T05:43:27.637 回答