Android: dlaczego PhoneCallListener nadal żyje po zakończeniu aktywności?
im używam słuchacza rozmowy telefonicznej w mojej działalności, ale po zakończeniu aktywności nawiązuję połączenie, a mój telefon nie słucha martwego i ponownie aktywuje aktywność !! proszę pomóż mi.
phoneListener = new PhoneCallListener();
telephonyManager = (TelephonyManager)
TransferActivity.this.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
Klasa PhoneCallListener:
private class PhoneCallListener extends PhoneStateListener {
boolean isPhoneCalling = false;
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (TelephonyManager.CALL_STATE_RINGING == state) {
}
if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
isPhoneCalling = true;
}
if (TelephonyManager.CALL_STATE_IDLE == state) {
if (isPhoneCalling) {
isPhoneCalling = false;
Intent intent = getIntent();
startActivity(intent);
}
}
}
}
}