阻止来电,即使只有不到一秒的时间 android

发布于 2024-12-14 13:41:27 字数 874 浏览 3 评论 0原文

我使用了以下代码:

问题:它工作正常并阻止来电,但电话在断开呼叫之前响了几分之一秒。有没有我正在寻找的解决方案。

public class CallReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) { 
        Bundle b = intent.getExtras();                     
        incomingNumber1 =   b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
        TelephonyManager telephony = (TelephonyManager)context
                                .getSystemService(Context.TELEPHONY_SERVICE);
        Class c = Class.forName(telephony.getClass().getName());    
        Method m = c.getDeclaredMethod("getITelephony");
        m.setAccessible(true);
        telephonyService = (ITelephony) m.invoke(telephony);          
        telephonyService.endCall(); 
}}

我还没有找到问题的答案。我想要在 Android 2.3 上完美运行的解决方案。来电要完全屏蔽,不得有响铃。

i have used the following code:

Problem: It is working fine and blocking incoming call but phone ring for fraction of a second before disconnect the call. can there be a solution which i am looking for .

public class CallReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) { 
        Bundle b = intent.getExtras();                     
        incomingNumber1 =   b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
        TelephonyManager telephony = (TelephonyManager)context
                                .getSystemService(Context.TELEPHONY_SERVICE);
        Class c = Class.forName(telephony.getClass().getName());    
        Method m = c.getDeclaredMethod("getITelephony");
        m.setAccessible(true);
        telephonyService = (ITelephony) m.invoke(telephony);          
        telephonyService.endCall(); 
}}

I have not found the answer to the problem yet. I want solution which work perfectly on Android 2.3. Incoming call is to be blocked fully there must not any ring.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文