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

  1. Open your device's Settings app.
  2. Tap Sound, then Do Not Disturb preferences, then Priority only allows.
  3. 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

  1. Swipe down from the top of your screen with 2 fingers.
  2. Under Do not disturb or your current option, tap the Down arrow.
  3. Turn on Do not disturb.
  4. Pick Priority only.
  5. Choose how long you want this setting to last.
  6. 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.