一.介绍
在应用层监听通话状态只有三种,从TelephonyManager.java中注释可知这三种状态含义如下:
CALL_STATE_IDLE 空闲态(没有通话活动)
CALL_STATE_RINGING 包括响铃、第三方来电等待
CALL_STATE_OFFHOOK 包括dialing拨号中、active接通、hold挂起等
由上可知,active接通状态没有单独给出,所以我们无法得知电话是否接通了,
因此需要其它手段来获取更多的精确通话状态,遍查网络资料,一般有两种方法!
public class TelephonyManager {
/** Device call state: No activity. */
public static final int CALL_STATE_IDLE = 0;
/** Device call state: Ringing. A new call arrived and is
* ringing or waiting. In the latter case, another call is
* already active. */
public static final int CALL_STATE_RINGING = 1;
/** Device call state: Off-hook. At least one call exists
* that is dialing, active, or on hold, and no calls are ringing
* or waiting. */
public static final int CALL_STATE_OFFHOOK = 2;