【问题标题】:Is there a way on Android to intercept incoming calls/SMSes to either block/unblock it?Android上有没有办法拦截来电/短信以阻止/取消阻止它?
【发布时间】:2011-01-25 07:10:30
【问题描述】:

有没有办法根据添加到筛选列表的手机号码来拦截来电/短信(阻止或解除阻止)?

【问题讨论】:

    标签: android


    【解决方案1】:

    ----> 对于您的问题,我认为以下内容会有所帮助。

    package android_programmers_guide.PhoneCallReceiver;
    import java.lang.reflect.Method;
    import com.android.internal.telephony.ITelephony;
    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    import android.telephony.TelephonyManager;
    import android.util.Log;
    import android.widget.Toast;
    public class PhoneCallReceiver extends BroadcastReceiver
    {
        Context context = null;
        private static final String TAG = "THIRI THE WUT YEE";
        private ITelephony telephonyService;
        @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);
    
                Toast tag = Toast.makeText(context, "Call is not allowed in the meeting!!!", Toast.LENGTH_LONG);
                tag.setDuration(25);
                tag.show();
    
    
                telephonyService.silenceRinger();
                telephonyService.endCall();
            } 
            catch (Exception e) 
            {
                e.printStackTrace();
            }
    
     }
    
    
    }
    

    -----> 这里是接口类

    package com.android.internal.telephony;
    interface ITelephony 
    {
        boolean endCall();
        void answerRingingCall();
        void silenceRinger();
    }
    

    ----> Manifest 如下

        <application android:icon="@drawable/icon" android:label="@string/app_name">
            <activity android:name=".PhoneCall2"
                      android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
    
            </activity>
            <receiver  android:name=".PhoneCallReceiver">
                <intent-filter  android:priority="100" >
                    <action android:name="android.intent.action.PHONE_STATE" />
                </intent-filter>
            </receiver>
    
    
        </application>
        <uses-sdk android:minSdkVersion="3" />
        <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
        <uses-permission android:name="android.permission.CALL_PHONE" />
        <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    
    </manifest> 
    

    ---> 老实说,我在互联网上找到了这段代码 干杯!

    【讨论】:

    • 似乎是内部 API 的 nick hack
    【解决方案2】:

    据我所知,无法修改接听电话的应用程序。 不过,请参阅 How to block calls in android 获取一些创意建议。

    似乎有一个用于删除 SMS 的解决方法,请参阅 How to delete an SMS from the inbox in Android programmatically?.

    但应用程序这样做是非常值得怀疑的,因为副作用可能很严重。确保您的用户理解这一点! 恕我直言,最好的解决方案是单独构建一个支持这些儿童安全功能的 android(我认为这就是您想要使用它的目的)。

    【讨论】:

      【解决方案3】:

      好吧,如果您正在寻找一款应用,那么 Android 市场上肯定有许多呼叫拦截应用。我建议使用以下免费应用程序来执行此操作以及更多功能: https://play.google.com/store/apps/details?id=cloud4apps.cBlocker

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-08-22
        • 2020-11-03
        • 1970-01-01
        • 2013-08-25
        • 2013-04-19
        • 1970-01-01
        相关资源
        最近更新 更多