如何檢測傳出呼叫連接。我的代碼如下,但有incomingcall若在該得到,如果(intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING))如何檢測傳出呼叫連接android
時,沒有活動就在這個
得到否則如果(intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_IDLE))
當incomingcall是回答它會得到這個和它的呼叫它會得到這個。
否則,如果(intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_OFFHOOK))
,現在當outgoingcall它的狀態是摘機我怎麼能知道我的outgoingcall連接時。
謝謝
@Override
public void onReceive(Context context, Intent intent) {
// TODO: This method is called when the BroadcastReceiver is receiving
// an Intent broadcast.
if(intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING)){
String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
Toast.makeText(context, "Call From : " + incomingNumber, Toast.LENGTH_LONG).show();
}
else if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_IDLE)){
Toast.makeText(context,TelephonyManager.EXTRA_STATE_IDLE,Toast.LENGTH_LONG).show();
}
else if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_OFFHOOK)){
Toast.makeText(context,TelephonyManager.EXTRA_STATE_OFFHOOK,Toast.LENGTH_LONG).show();
}
}
http://stackoverflow.com/questions/12039098/android-detecting-when-lines-have-been-connected-during-an-outgoing-call請檢查下面的鏈接。 –