如何筛选进来的电话(黑名单) - 无反射 [英] How to filter incomming calls (blacklist) - no reflection

查看:271
本文介绍了如何筛选进来的电话(黑名单) - 无反射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果有,我可以过滤在Android(块)来电(考虑2.1及更高版本)的方式。我发现使用反射解决方案,但它似乎不是非常干净和可靠的解决方案。是否有任何标准或谷歌推荐的方式做到这一点?

I was wondering if there is a way that I can filter (block) incoming calls on Android (consider 2.1 and up). I found solutions using reflection, but it seem not to be very clean and reliable solution. Is there any standard or google recommended way to do that?

更新:任何

推荐答案

使用下面的广播接收器来获取来电号码,并将其与在你创建的过滤器列表中的号码比较

use the following broadcast receiver to get the incoming phone number and compare it with the numbers that are in your created filter list

@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null) {
        String state = extras.getString(TelephonyManager.EXTRA_STATE);
        Log.w("DEBUG", state);
        if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
            String phoneNumber = extras
                    .getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
            Toast.makeText(context, phoneNumber, 2000).show();
            Log.w("DEBUG", phoneNumber);
        }
    }
}

希望这会有所帮助。您需要通过应用程序的用户界面来创建数字的黑名单列表。

Hope it will help. You need to create a list of numbers in blacklist by your application's User interface.

这篇关于如何筛选进来的电话(黑名单) - 无反射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆