Search code examples
androidcalldelayforward

Android : Set Call forwarding after a delay


I am trying to set call forwarding option in my App with a delay. Like I get call, It displays for 5 or 10 sec, So I see, if its from my family or friends I can pick the call, Or else after the delay, It should automatically be forwarded to the set mobile number.

I have written the below function to set forward.

Help me to add delay to it like 5 sec or 10 sec.

void fwdCalSetSecBtnFnc()
{
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED)
    {
        Intent calFwdIntentVar = new Intent(Intent.ACTION_CALL);
        String mobNumVar = FwdMobNumTxt.getText().toString();
        String fwdMobNumVar = ("**21*" + mobNumVar + "#");
        calFwdIntentVar.setData(Uri.fromParts("tel", fwdMobNumVar, "#"));
        calFwdIntentVar.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(calFwdIntentVar);
    }
}

Solution

  • UUID Code Links :
    http://www.theunwired.net/?item=how-to-diverting-voice-calls-by-using-ussd-codes>

    UUID Code 21 Diverts all Calls

    So to Divert if no Reply we have to Use UUID Code 61

    So Replace :

    String fwdMobNumVar = ("**21*" + mobNumVar + "#");
    

    with

    => For 5 Sec Delay :

    String fwdMobNumVar = ("**61*" + mobNumVar + "*" + 5 + "#");
    

    => For 10 Sec Delay :

    String fwdMobNumVar = ("**61*" + mobNumVar + "*" + 10 + "#");