24-Android监听精确的通话状态

Android监听精确的通话状态

添加权限

<uses-permission android:name="android.permission.READ_PRECISE_PHONE_STATE" />

设置监听

TelephonyManager manager = (TelephonyManager) mApplication.getSystemService(Context.TELEPHONY_SERVICE);
manager.listen(new PhoneStateListener() , PhoneStateListener.LISTEN_CALL_STATE | PhoneStateListener.LISTEN_PRECISE_CALL_STATE);
PhoneStateListener.LISTEN_CALL_STATE | PhoneStateListener.LISTEN_PRECISE_CALL_STATE必须同时存在
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页