Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Redirect outgoing calls

I'm trying to redirect outgoing calls to a different phone number on an Android device. So, I use a BroadcastReceiver "listening" for the NEW_OUTGOING_CALL intent, on his onReceive() method I use the setResultData() method to change the phone number.

Like this:

public void onReceive(Context arg0, Intent arg1) {
    
    setResultData("351978923221");

}

In the emulator all goes well, but on my real device (a crappy ZTE X850 with Android 2.1 I believe) it doesn't if the calling Intent originates in an Activity which is part of the same application. After the dialing screen appears, the phone terminates the call.

Any thoughts out there on why this happens?

Note: I know my question is basically the same as this one but I chose to ask it again anyway to provide additional details about what goes wrong.


Manifest File

An excerpt...

    <receiver android:name=".OutgoingCallDetection" android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.NEW_OUTGOING_CALL"
                    android:priority="9999" />
        </intent-filter>
    </receiver>

</application>

<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
like image 673
André Maricato Avatar asked Sep 10 '10 09:09

André Maricato


People also ask

Can outgoing calls be diverted?

Call forwarding is often enabled by dialing *72 followed by the telephone number to which calls should be forwarded. Once someone answers, call forwarding is in effect. If no one answers or the line is busy, the dialing sequence must be repeated to effect call forwarding. Call forwarding is disabled by dialing *73.

What is call redirection service in Android?

android.telecom.CallRedirectionService. This service can be implemented to interact between Telecom and its implementor for making outgoing call with optional redirection/cancellation purposes.


1 Answers

I cut the dialed call and redialed the new call. It worked perfectly on the device.

This is the code part:

setResultData(null);
Uri uri = Uri.fromParts("tel", "!Number to be dialed!", null);
Intent newIntent = new Intent(Intent.ACTION_CALL, uri);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);

Hope this helps.

like image 185
Rita Avatar answered Sep 18 '22 17:09

Rita