javaandroidmobileairplane-modecallblocking

How to make number not reachable (similar to call blocker)?


There are lot of call blocking application for mobile, like NQ Call Blocker. But in these applications, if we add a number to blacklist, the caller will hear "Busy Tone". Also the caller can hear "Ringing Tone" for a fraction of second. Which means, it'd look like we are rejecting the call intentionally.

Now, what I'm trying is, to develop an call blocking application, which can send "Not Reachable Tone", instead of "Busy Tone" ... ??

For example, call your mobile from another number, when it's ringing, try to change your mode to "Airplane Mode". You'll hear "Not Reachable Tone". [Possible in some android device, long press the power button, and activate "Airplane mode", when your mobile is ringing.]


Solution

  • You could try to implement a PhoneStateListener and when you receive a call you compare it to you array of numbers, if it is forbidden you switch to airplaine mode. Something like this:

    case TelephonyManager.CALL_STATE_RINGING: // incoming call
    {
        for (int i = 0; i < forbiddenNumber.size; i++) {
            if (incomingNumber.equals(forbiddenNumber[i])) {
                // read the airplane mode setting
                boolean isEnabled = Settings.System.getInt(
                        getContentResolver(),
                        Settings.System.AIRPLANE_MODE_ON, 0) == 1;
    
                // toggle airplane mode
                Settings.System.putInt(getContentResolver(),
                        Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0
                                : 1);
    
                // Post an intent to reload
                Intent intent = new Intent(
                        Intent.ACTION_AIRPLANE_MODE_CHANGED);
                intent.putExtra("state", !isEnabled);
                sendBroadcast(intent);
    
            }
        }
    

    Don't forget the permission to WRITE_SETTINGS