A simple Android app to block unwanted calls using pattern matching with wildcards.
๐ Live Preview | ๐ฆ Download APK
- Pattern Matching - Flexible wildcards for matching phone numbers
*= match zero or more digits?= match exactly one digit86*blocks ALL numbers starting with 86138????????blocks 11-digit numbers starting with 138
- Four Actions:
- โ Allow - Whitelist (highest priority, checked first)
- ๐ซ Block - Reject the call completely
- ๐ Silence - Mute ringer, call still visible
- ๐ Voicemail - Decline to voicemail
- Priority System - ALLOW rules are always checked first
- Call Log - View incoming calls with raw number format
- Enable/Disable - Toggle individual rules on/off
- Simple UI - Easy to add, manage, and delete rules
- Android 10+ (API 29+)
- Permissions: Phone, Call Logs
- Download the latest APK from Releases
- Enable "Install from unknown sources" in Settings
- Open the APK file to install
- Launch the app and grant permissions when prompted
After installing, you need to grant permissions:
-
Settings โ Apps โ Phone Blocker โ Permissions
- Enable: Phone (็ต่ฏ)
- Enable: Call Logs (้่ฏ่ฎฐๅฝ)
-
Set as Call Screening App (if prompted):
- Settings โ Apps โ Default Apps โ Caller ID & Spam
- Select: Phone Blocker
Note: Some phones (especially Chinese ROMs like MIUI, ColorOS, etc.) may not show the Call Screening option. The app includes a fallback method that works on most devices.
- Tap the + button
- Enter pattern using digits and wildcards (
*?) - Select action: Allow, Block, Silence, or Voicemail
- Tap Add
The app strips all non-digit characters from incoming numbers before matching:
+8613812345678becomes8613812345678183+23456312becomes18323456312(021) 555-1234becomes0215551234
| Wildcard | Meaning | Example |
|---|---|---|
* |
Zero or more digits | 86* matches 86, 861, 8612345678 |
? |
Exactly one digit | 138???????? matches any 11-digit number starting with 138 |
| Pattern | Matches | Use Case |
|---|---|---|
86* |
All numbers starting with 86 | Block all China numbers |
865* |
Numbers starting with 865 | Allow specific prefix (use with ALLOW) |
138???????? |
11-digit numbers starting with 138 | Block specific carrier prefix |
1800* |
Numbers starting with 1800 | Block toll-free numbers |
????1234 |
8-digit numbers ending with 1234 | Block numbers with specific suffix |
* |
ALL numbers | Block everything (use ALLOW rules for exceptions) |
To block all China numbers EXCEPT a specific prefix:
- Add rule:
865*โ Allow (checked first) - Add rule:
86*โ Block (checked second)
Result: 8651234567 is allowed, 8612345678 is blocked.
Tap ๐ Log to view incoming calls:
- Shows raw phone number format
- Shows matched pattern (if any)
- Status: ALLOW, BLOCK, SILENCE, VOICEMAIL, or NOT MATCH
- JDK 17
- Android SDK (API 34)
- Gradle 8.2+
# Install JDK 17
sudo apt install openjdk-17-jdk
# Set up Android SDK
mkdir -p ~/Android/cmdline-tools
cd ~/Android/cmdline-tools
wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
unzip commandlinetools-linux-11076708_latest.zip
mv cmdline-tools latest
# Set environment variables
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export ANDROID_HOME=~/Android
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
# Install SDK components
yes | sdkmanager --licenses
sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"
# Clone and build
git clone https://github.com/johnwmail/phone-blocker.git
cd phone-blocker
./gradlew assembleDebug
# APK will be at:
# app/build/outputs/apk/debug/app-debug.apk- Install JDK 17
- Install Android Studio (includes SDK)
- Open project in Android Studio
- Build โ Build Bundle(s) / APK(s) โ Build APK(s)
./gradlew testDebugUnitTestphone-blocker/
โโโ .github/workflows/
โ โโโ test.yml # CI: test & lint on push/PR
โ โโโ release.yml # CI: build & release on tag
โโโ docs/ # GitHub Pages
โ โโโ index.html # Download page
โ โโโ preview.html # Interactive UI preview
โโโ app/
โ โโโ src/main/
โ โ โโโ java/com/phoneblocker/
โ โ โ โโโ MainActivity.kt # Main UI
โ โ โ โโโ BlockRule.kt # Rule data model & matching
โ โ โ โโโ RuleStorage.kt # Save/load rules (with priority)
โ โ โ โโโ RuleAdapter.kt # RecyclerView adapter
โ โ โ โโโ CallBlockerService.kt # CallScreeningService (Android 10+)
โ โ โ โโโ CallReceiver.kt # BroadcastReceiver fallback
โ โ โ โโโ CallLogActivity.kt # Call log viewer
โ โ โ โโโ CallLogStorage.kt # Call log storage
โ โ โโโ res/
โ โ โ โโโ layout/ # UI layouts
โ โ โ โโโ menu/ # Menu resources
โ โ โ โโโ values/ # Colors, strings, themes
โ โ โ โโโ drawable/ # Icons
โ โ โโโ AndroidManifest.xml
โ โโโ src/test/
โ โ โโโ java/com/phoneblocker/
โ โ โโโ BlockRuleTest.kt # Unit tests
โ โโโ build.gradle.kts
โโโ build.gradle.kts
โโโ settings.gradle.kts
โโโ README.md
The app uses two methods to block calls:
-
CallScreeningService (Android 10+)
- Official Android API for call screening
- Requires being set as default Call Screening app
- May not work on all custom ROMs
-
BroadcastReceiver Fallback
- Listens for
PHONE_STATEbroadcasts - Uses
TelecomManager.endCall()to reject calls - Works on most phones including custom ROMs
- Listens for
| Action | Behavior | Notification |
|---|---|---|
| Block | Reject immediately | No notification |
| Silence | Mute ringer, call visible | User can answer/decline |
| Voicemail | Decline (routes to voicemail) | Missed call notification |
- ALLOW rules are always checked first
- If an ALLOW rule matches โ call is allowed
- BLOCK/SILENCE/VOICEMAIL rules are checked next
- If a blocking rule matches โ action is taken
- If no rule matches โ call is allowed (logged as "NOT MATCH")
- Check permissions: Ensure Phone and Call Logs permissions are granted
- Check the pattern: Use the Call Log to see the raw number format
- Check rule is enabled: Toggle switch should be ON (blue)
- Try full number: Test with the exact phone number (no wildcards) first
- Let a call come through
- Open ๐ Log to see the raw number
- Create a pattern based on that format
Some phones hide the Call Screening option. The app's BroadcastReceiver fallback should still work.
Some phones require additional permissions. Go to:
- Settings โ Apps โ Phone Blocker โ Permissions โ Grant all available permissions
For Chinese ROMs (Xiaomi, OPPO, Vivo):
- Enable "Autostart" permission
- Disable battery optimization for the app
The project uses GitHub Actions for continuous integration:
-
test.yml - Runs on push to
main/devand PRs- Runs unit tests
- Runs Android lint
- Builds APK
-
release.yml - Runs on tag push (
v*)- Builds debug and release APKs
- Creates GitHub Release with APKs attached
To create a release:
git tag v0.0.3
git push origin v0.0.3MIT License - Feel free to use and modify.
Pull requests welcome! Please:
- Run tests before submitting:
./gradlew testDebugUnitTest - Test on multiple devices if possible
- Update documentation for new features