检测android中特定号码的误拨

检测android中特定号码的误拨,android,Android,有人能告诉我吗?我正在制作一个样本,希望检测某个特定号码的未接来电。假设我打开了电话号码0123456789的拨号器,当我拨打这个号码时,就会检测到这个号码的未接来电。我该怎么做呢。请帮忙 检查流动代码-> 在广播接收器中,检查是否收到呼叫。然后您可以找到呼叫状态 public class CallBroadcast extends BroadcastReceiver { private static boolean isMissedCall; @Override p

有人能告诉我吗?我正在制作一个样本,希望检测某个特定号码的未接来电。假设我打开了电话号码0123456789的拨号器,当我拨打这个号码时,就会检测到这个号码的未接来电。我该怎么做呢。请帮忙

检查流动代码->

在广播接收器中,检查是否收到呼叫。然后您可以找到呼叫状态

public class CallBroadcast extends BroadcastReceiver {

    private static boolean isMissedCall;

    @Override
    public void onReceive(Context context, Intent intent) {

        Bundle bundle = intent.getExtras();

        try {
            if (bundle != null) {

                String state = bundle.getString(TelephonyManager.EXTRA_STATE);

                if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                    // Ringing
                    isMissedCall = true;
                } else if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
                    // Call Received
                    isMissedCall = false;
                } else if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
                    // Call Drop
                    // If don't receive call then it will be missed call
                    if(isMissedCall){
                        // do your code for missed call
                    }
                }
            }
        }catch (Exception e){e.printStackTrace();}

    }
}