Android判断当前正在通话(电话呼入)的状态
16lz
2021-01-23
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; //至少有一个通话存在
更多相关文章
- Android:监听WIFI网络状态
- android监听手机网络连接状态改变的后台服务
- android 实时检测网络状态
- android 把图片状态由彩色变成灰色
- android中gridView中点击 item为选中状态
- android屏幕监听,手机是否处于锁屏状态,在锁屏之上弹出Toast.makeT
- 禁止状态栏下拉
- Android中View(视图)绘制不同状态背景图片原理深入分析以及State