2012-11-29 48 views
0

我試圖發起AA電話中Broadcast.At的情況下,我從廣播receiver.In的的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 

+0

<使用許可權的android:NAME = 「android.permission.CALL_PHONE」/> – omar

+0

請張貼的logcat日誌... –

+0

你碰巧找到解決辦法?我遇到同樣的問題 – javaLovah

回答

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); 
+0

我已將Logcats添加到問題仍然存在的問題中。 – omar

+0

任何人?有同樣的問題。 – omar