Android - Block calls for everyone except for contacts
Although you mentioned using Android 4.1.2, I recently stumbled across this question and thought a more recent answer might be useful to others:
On Android 5.0 "Lollipop" and later this can be accomplished using the "Priority only" Do Not Disturb mode:
Configure Do Not Disturb Priority Allowances
- Open your device's Settings app.
- Tap Sound, then Do Not Disturb preferences, then Priority only allows.
- Set Calls to From contacts only and adjust any other preferences for this mode to your liking.
Turn on Do Not Disturb "Priority only" mode
- Swipe down from the top of your screen with 2 fingers.
- Under Do not disturb or your current option, tap the Down arrow.
- Turn on Do not disturb.
- Pick Priority only.
- Choose how long you want this setting to last.
- Tap Done.
The app Blacklist Plus mentions exactly that as one possible use:
There are four block modes of call blocker:
- Blacklist
- All except the whitelist
- All except contacts
- All numbers
(emphasis mine). There are plenty other similar apps available, just search for "blacklist" or "call blocker" on the playstore.