public boolean isTelephonyCalling(){
boolean calling = false;
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if(TelephonyManager.CALL_STATE_OFFHOOK==telephonyManager.getCallState()||TelephonyManager.CALL_STATE_RINGING==telephonyManager.getCallState()){
calling = true;
}
return calling;
}
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; //至少有一个通话存在