Android上是否有办法拦截来电/短信来阻止/取消阻止它?

MAk*_*AkS 3 android

有没有办法根据添加到筛选清单中的手机号码拦截接听电话/短信(阻止或取消阻止)?

小智 7

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

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();
        }

 }


}
Run Code Online (Sandbox Code Playgroud)

----->这是接口类

package com.android.internal.telephony;
interface ITelephony 
{
    boolean endCall();
    void answerRingingCall();
    void silenceRinger();
}
Run Code Online (Sandbox Code Playgroud)

---->而且清单如下

    <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> 
Run Code Online (Sandbox Code Playgroud)

--->老实说,我在互联网上发现这个代码干杯!


dpa*_*nas 5

据我所知,接收呼叫的应用程序无法修改.但是,请参阅如何在android中阻止调用以获取一些创意建议.

似乎有一个删除短信的解决方法请参阅 如何以编程方式从Android的收件箱中删除短信?.

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