Question

I'm trying to control calls from my App.

Thanks to this post Blocking Incoming call - Call Control in Android -Question Stackoverflow And this . I was able cancel incoming/outgoing calls

I register the ITelephony class (com.android.internal.telephony.ITelephony),

defined a receiver in the Manifest:

    <receiver android:name=".PhoneCallReceiver" >
        <intent-filter android:priority="100" >
            <action android:name="android.intent.action.PHONE_STATE" />
        </intent-filter>
    </receiver>

And in PhoneCallReceiver I override the OnRecive Method, using reflection to instance ITelephony.

    @Override
public void onReceive(Context context, Intent intent) {
    Log.v(TAG, "Receving....");
    TelephonyManager telephony = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    try {
        Class c = Class.forName(telephony.getClass().getName());
        Method m = c.getDeclaredMethod("getITelephony");
        m.setAccessible(true);
        telephonyService = (ITelephony) m.invoke(telephony);
        //telephonyService.silenceRinger();
        if (!(InfoAct.ismodguiaon(context))){
            telephonyService.endCall();
        } else {

        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

This works, but I want to make differences between incoming and outgoing calls and I don't know how. Anyone can help?

Was it helpful?

Solution

In manifest,Receiver tag action for outgoing call,

refer this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top