【问题标题】:block / unblock Calls. Differencing between incoming / outgoing阻止/取消阻止呼叫。传入/传出之间的区别
【发布时间】:2012-07-18 10:42:32
【问题描述】:

我正在尝试控制来自我的应用程序的调用。

感谢这篇帖子Blocking Incoming call - Call Control in Android -Question Stackoverflowthis。我可以取消来电/去电

我注册了 ITelephony 类 (com.android.internal.telephony.ITelephony),

在 Manifest 中定义了一个接收者:

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

在 PhoneCallReceiver 中,我重写了 OnRecive 方法,使用反射来实例 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();
    }

}

这可行,但我想区分来电和去电,但我不知道如何。任何人都可以帮忙吗?

【问题讨论】:

    标签: android callblocking


    【解决方案1】:

    在清单中,接收者标签动作 拨出电话,

    参考this

    【讨论】:

    • 正是我想要的。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2020-09-30
    • 2014-05-12
    • 1970-01-01
    • 2011-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多