都说打call就一句话的事,很简单。我却经常简单地方阴沟里翻船。
用下面的方法打 call,最后call not sent:
哪位大虾给解答一下???
===add on 2013-12-25====
此问题貌似与开发环境的模拟器上没有拨号键有关。
改用adt-boundle 之后,模拟器上有了拨号键,运行此程序也不再有问题,在手机上也能顺利拨打电话。
=====================
log文件: http://download.youkuaiyun.com/detail/qdulgh/6728447
12-17 01:00:49.300: D/CallGatewayManager(1300): checkAndCopyPhoneProviderExtras: some or all extras are missing.
12-17 01:00:49.310: I/ActivityManager(1048): START u0 {act=com.android.phone.SIP_SELECT_PHONE dat=tel:xxxxxxxxxx flg=0x10000000 cmp=com.android.phone/.SipCallOptionHandler (has extras)} from pid 1300
12-17 01:00:49.520: I/Choreographer(1300): Skipped 79 frames! The application may be doing too much work on its main thread.
12-17 01:00:50.010: W/ActivityManager(1048): Activity pause timeout for ActivityRecord{b2040a50 u0 com.android.phone/.OutgoingCallBroadcaster t2}
12-17 01:00:50.440: D/gralloc_goldfish(1300): Emulator without GPU emulation detected.
12-17 01:00:51.600: I/Choreographer(1048): Skipped 42 frames! The application may be doing too much work on its main thread.
12-17 01:00:51.970: I/Choreographer(1048): Skipped 35 frames! The application may be doing too much work on its main thread.
12-17 01:00:52.430: D/CallController(1300): placeCall()... intent = Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxx (has extras) }
12-17 01:00:52.590: D/PhoneUtils(1300): placeCall()... number: xxxxxxxxxx, GW: null, emergency? false
12-17 01:00:53.060: I/MediaFocusControl(1048): AudioFocus requestAudioFocus() from AudioFocus_For_Phone_Ring_And_Calls
12-17 01:00:53.190: I/ActivityManager(1048): Start proc android.process.acore for content provider com.android.providers.contacts/.ContactsProvider2: pid=1861 uid=10002 gids={50002, 3003, 1028, 1015}
12-17 01:00:53.960: D/MobileDataStateTracker(1048): default: Broadcast received: android.intent.action.ANY_DATA_STATE apnType=default
12-17 01:00:54.090: D/MobileDataStateTracker(1048): default: Received state=SUSPENDED, old=CONNECTED, reason=2GVoiceCallStarted
12-17 01:00:54.090: D/MobileDataStateTracker(1048): default: setDetailed state, old =CONNECTED and new state=SUSPENDED
12-17 01:00:54.190: D/MobileDataStateTracker(1048): fota: Broadcast received: android.intent.action.ANY_DATA_STATE apnType=fota
12-17 01:00:54.240: D/MobileDataStateTracker(1048): fota: Received state=DISCONNECTED, old=DISCONNECTED, reason=2GVoiceCallStarted
12-17 01:00:54.280: D/MobileDataStateTracker(1048): ia: Broadcast received: android.intent.action.ANY_DATA_STATE apnType=ia
12-17 01:00:54.360: D/MobileDataStateTracker(1048): ia: Received state=DISCONNECTED, old=DISCONNECTED, reason=2GVoiceCallStarted
12-17 01:00:54.410: D/MobileDataStateTracker(1048): supl: Broadcast received: android.intent.action.ANY_DATA_STATE apnType=supl
12-17 01:00:54.440: D/ConnectivityService(1048): ConnectivityChange for mobile: SUSPENDED/SUSPENDED
12-17 01:00:54.570: D/ConnectivityService(1048): tryFailover: set mActiveDefaultNetwork=-1, prevNetType=0
12-17 01:00:54.640: D/ConnectivityService(1048): Attempting to switch to wifi
12-17 01:00:54.890: D/MobileDataStateTracker(1048): supl: Received state=DISCONNECTED, old=DISCONNECTED, reason=2GVoiceCallStarted
12-17 01:00:54.890: D/MobileDataStateTracker(1048): hipri: Broadcast received: android.intent.action.ANY_DATA_STATE apnType=hipri
12-17 01:00:54.950: D/MobileDataStateTracker(1048): hipri: Received state=DISCONNECTED, old=DISCONNECTED, reason=2GVoiceCallStarted
12-17 01:00:55.090: D/NetUtils(1048): android_net_utils_resetConnections in env=0xb836c4f8 clazz=0x6ff00001 iface=eth0 mask=0x3
12-17 01:00:55.090: D/ConnectivityService(1048): resetConnections(eth0, 3)
12-17 01:00:55.230: D/MobileDataStateTracker(1048): ims: Broadcast received: android.intent.action.ANY_DATA_STATE apnType=ims
12-17 01:00:55.300: D/MobileDataStateTracker(1048): ims: Received state=DISCONNECTED, old=DISCONNECTED, reason=2GVoiceCallStarted
12-17 01:00:55.350: D/MobileDataStateTracker(1048): mms: Broadcast received: android.intent.action.ANY_DATA_STATE apnType=mms
12-17 01:00:55.450: D/MobileDataStateTracker(1048): mms: Received state=DISCONNECTED, old=DISCONNECTED, reason=2GVoiceCallStarted
12-17 01:00:55.450: D/MobileDataStateTracker(1048): cbs: Broadcast received: android.intent.action.ANY_DATA_STATE apnType=cbs
12-17 01:00:55.490: D/MobileDataStateTracker(1048): cbs: Received state=DISCONNECTED, old=DISCONNECTED, reason=2GVoiceCallStarted
12-17 01:00:55.520: I/Choreographer(1300): Skipped 196 frames! The application may be doing too much work on its main thread.
: E/(): Device disconnected: 1
: E/(): Device disconnected
代码:
//method to make call
private void makeCall(String num){if ((num!=null)&&(!"".equals(num.trim()))){
Toast.makeText(MyListView3.this, "calling number: " + num, Toast.LENGTH_SHORT).show();
Intent intent=new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+num));
startActivity(intent);
}
}
//在下面调用makeCall的
@Override
protected void onListItemClick(ListView parent, View v, int position, long id) {
Toast.makeText(MyListView3.this, "You click: " + position, Toast.LENGTH_SHORT).show();
super.onListItemClick(parent, v, position, id);
ListView lv = (ListView)parent;
HashMap<String,Object> map=(HashMap<String,Object>)lv.getItemAtPosition(position);
Object Ctitle=map.get("title");
Object Cinfo=map.get("info");
Object Cmail=map.get("mail");
// final TextView tel=(TextView) v.findViewById(R.id.info);
Toast.makeText(this, "phone num is:"+Cinfo, Toast.LENGTH_SHORT).show();
makeCall(Cinfo.toString());
}