添加权限
<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必须同时存在