如何捕获和阻止未知来电

时间:2014-05-01 12:07:57

标签: android broadcastreceiver

我有问题。我的接收器运行非常成功但是当私人号码不能正常运行我的代码。

private class MyPhoneStateListener extends PhoneStateListener {

    public void onCallStateChanged(int state, String incomingNumber) {

        Log.d("MyPhoneListener", state + "   incoming no:" + incomingNumber);

        if (state == 1) {

            Cursor numaralar = NumaralariGetir();

            while (numaralar.moveToNext()) {

                String numara = numaralar.getString(numaralar
                        .getColumnIndex("numara"));
                if (incomingNumber.equals(numara)) { // DialedNumber
                                                        // checking.
                    abortBroadcast();
                }
            }

        }
    }
}