I use Broadcast receiver to catch Phone state Change.
It works fine when the state change in in first time (for State_OffHook), but don’t react when the call ends.
This is my code:
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (TelephonyManager.EXTRA_STATE_OFFHOOK.equals(state)) {working fine}
else if (TelephonyManager.EXTRA_STATE_IDLE.equals(state)) {doesn't react}
When you have no call you are in
IDLEstate and when you get a call it goes toOFFHOOKstateand when your call ends it again goes to
IDLEstatefor more info
refer this
How to know whether I am in a call on Android?
EDIT: