I want to perform some action when reject button is pressed for any incoming call. I have gone through the official documentation TelephonyManager but it doesn't satisfy my need.
I have tried with this with no success.
public class Call_Receiver extends BroadcastReceiver {
private Context ctx;
@Override
public void onReceive(Context context, Intent intent) {
ctx = context;
OutgoingIncomingCallListener phoneListener = new OutgoingIncomingCallListener();
TelephonyManager telephony = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
if (intent.getAction()
.equals("android.intent.action.NEW_OUTGOING_CALL")) {
telephony.listen(phoneListener,
PhoneStateListener.LISTEN_CALL_STATE);
}
}
class OutgoingIncomingCallListener extends PhoneStateListener {
public boolean wasRinging;
@Override
public void onCallStateChanged(int state, String incomingNumber) {
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
wasRinging = true;
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.i("", " *********** OFFHOOK ********");
wasRinging = true;
break;
case TelephonyManager.CALL_STATE_IDLE:
if (wasRinging) {
Toast.makeText(ctx,
"Your call is disconnected by receiver", 10000)
.show();
}
wasRinging = true;
break;
}
}
}
}
It's showing me toast when receiver rejects the call but I want to do it from caller side.
So all I want to find the event when someone presses reject button for any incoming call.
How do I do this?