Android判断当前正在通话(电话呼入)的状态

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; //至少有一个通话存在


发布了29 篇原创文章 · 获赞 23 · 访问量 15万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览