How to filter incomming calls (blacklist) - no reflection

送分小仙女□ 提交于 2019-12-06 07:16:10

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!