views:

139

answers:

2

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 wich 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" />
A: 

I have the same issue and it seems to be a problem with "setResultData()" being ignored on 2.2

reekotubbs
In my case if I dial a 10 digit number like 555=555=5555 it does not work, neither does +1-555-555-5555. I am testing this on HTC EVO 4g with Froyo 2.2. My program does work on 2.1 which you appear to be on but not on 2.2. Anyone able to replicate this?
reekotubbs
+1  A: 

The issue i had was also similar one. What i did later was cut the diaed call and redial 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..

Rita