* 监听电话状态
*/
private void registerPhoneStateListener() {
- PhoneCallListener phoneCallListener = new PhoneCallListener();
+ Context applicationContext = getApplicationContext();
+ PhoneCallListener phoneCallListener = new PhoneCallListener(applicationContext);
TelephonyManager telephonyManager =
- (TelephonyManager) getApplicationContext().getSystemService(TELEPHONY_SERVICE);
+ (TelephonyManager) applicationContext.getSystemService(TELEPHONY_SERVICE);
if (telephonyManager != null) {
telephonyManager.listen(phoneCallListener, PhoneCallListener.LISTEN_CALL_STATE);
}