Android - Block all calls from area code unless in Contacts

beeshyams' solution did not work for me, but i was able to modify it and get it working. The issue that i encountered was that the "call incoming" trigger only happens once when you first receive the call. this means if you check for a boolean triggered by the incoming call, it won't be set yet.

first thing i did was find out what format i needed for the phone number by creating a very simple macro:

trigger: call incoming -> contacts -> any number
action: logging -> log event -> call number

i checked the logs and saw that the number was +12345678900. (im in the us)

next i deleted that macro and made the following:

T: call incoming (+1234*)
A: set variable (areacode: True)

T: call incoming (non contact)
A: set variable (noncon: True)

we are going to use the variables being set as our trigger to reject the call. these variables seemed to be set in a random/inconsistent order, so i just made two triggers, that way it didn't matter which was set first. this is a very janky solution, but it works.

T: macrodroid variable change (areacode = True)
A: call reject, set variable (areacode: False), set variable (noncon: False)
C: macrodroid variable (noncon = True)

T: macrodroid variable change (noncon = True)
A: call reject, set variable (areacode: False), set variable (noncon: False)
C: macrodroid variable (areacode = True)

finally, we need a way to reset the variables if our call blocking macros haven't been triggered. the best solution i found was to clear them after a call was completed or missed.

T: call missed (any number), call ended (any number),
A: call set variable (areacode: False), set variable (noncon: False)

i'm sure there is probably a more elegant solution, but this is at least working for me. (hooray, no more scam calls at 6am!) luckily there are exactly 5 free macros in the app, and 5 in my solution. if you have multiple area codes you need to block, you can put them all into the one macro with a separate trigger for each i think. (didn't test this)

all of this pain could be solved if you could have a trigger be caused by two conditions being met. that would mean we would only need a single macro, but from what i can tell, this isn't possible. unfortunately the constraints don't let you access the incoming call information so that doesn't work either. maybe there is a better app.

automation is the preferred option. Many apps are available. I prefer using MacroDroid , since it is free (upto 5 macros) and easy to learn.

You would need two macros for this

First macro would be to set a flag when the call is from an area code

Macro : Area code (name of macro as example)


  1. Call incoming → Select number → abc* ( where abc is numeric area code you are interested in and * is wildcard to represent any number . You need to know / experiment here - in my case I needed to type +<2digit country code><2 digit state code>< * wild card > to test with land line telephone

  2. You would need another similar trigger for identifying mobile numbers from that area if / as applicable

Action: Set Macrodroid Variable → New variable → from area code ( name of flag, it can be anything ) of type Boolean to true

Constraints: Leave blank

In the next macro we reject the call when the twin conditions of calling number is a non contact and from that area code are met

Macro : Reject call (name of macro as example)

Trigger: Call incoming → Select Contact → Non contact


  1. Call reject

    add constraint to this action by long pressing action

Macrodroid Variable →from area code = True (Macro only runs in this case, satisfying twin criteria conditions)

  1. Set Macrodroid Variable → from area code to false ( initialisation of flag )

Constraints: leave blank

I have only tested with landline available to me and it worked. Logic has been explained and you would need to configure with special attention to area codes of landline / mobile