Android 如何判斷撥打電話對方是否接聽

2021-07-31 00:01:05 字數 743 閱讀 5075

在開發中會遇到需要判斷使用者撥打**,對方是不是接通成功了。

解決方案: 

其實很簡單,只需要去系統的call_log表裡去查詢一下,本次的通話持續時間是否大於0,即可。 

**如下:

private boolean getcalllogstate() ,

calllog.calls

.number +"=? and "+calllog.calls

.type +"= ?",

new string,null);

while(cursor.movetonext()) else

}return false;

}

如果對方沒有接聽,則持續時間為0,即使聽筒中出現忙音或者提示語,這個表中的記錄值都為0。

**中的 calllog.calls.type 請自行選擇,列舉值如下

calllog.calls.type

//來電:1,呼出:2,未接:3

public

static

final

int incoming_type = 1;

public

static

final

int outgoing_type = 2;

public

static

final

int missed_type = 3;

android 撥打電話

引用 1.不用許可權 intent intent new intent intent.action dial uri data uri.parse tel 135 xx intent.setdata data startactivity intent 2.需要許可權 intent intent ne...

iOS撥打電話

1,這種方法,撥打完 回不到原來的應用,會停留在通訊錄裡,而且是直接撥打,不彈出提示 nsmutablestring str nsmutablestring alloc initwithformat tel 186 x6979 nslog str str 2,這種方法,打完 後還會回到原來的程式,也...

iOS 撥打電話

1.這種方法,撥打完 回不到原來的應用,會停留在通訊錄裡,而且是直接撥打,不彈出提示 nsmutablestring str nsmutablestring alloc initwithformat tel 186 x6979 2.這種方法,打完 後還會回到原來的程式,也會彈出提示,推薦這種 nsm...