How to block calls in android
I want to block calls from few numbers, for that I want to write a app 开发者_运维技巧of my own. So what are the APIs which I should be using?
Basically I want to get notified when a call comes, i want to compare numbers if it is what i want to block, i want to cut the call or mute it or if possible mute it and record it.
OMG!!! YES, WE CAN DO THAT!!! I was going to kill myself after severe 24 hours of investigating and discovering... But I've found "fresh" solution!
// "cheat" with Java reflection to gain access to TelephonyManager's
// ITelephony getter
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony)m.invoke(tm);
all all all of hundreds of people who wants to develop their call-control software visit this start point
there is a project. and there are important comments (and credits)
briefly: copy aidl file, add permissions to manifest, copy-paste source for telephony management )))
Some more info for you. AT commands you can send only if you are rooted. Than you can kill system process and send commands but you will need a reboot to allow your phone to receive and send calls =)))
I'm very hapy =) Now my Shake2MuteCall will get an update !
It is possible and you don't need to code it on your own.
Just set the ringer volume to zero and vibration to none if incomingNumber equals an empty string. Thats it ...
Its just done for you with the application Nostalk from Android Market. Just give it a try ...
In android-N, this feature is included in it. check Number-blocking update for android N
Android N now supports number-blocking in the platform and provides a framework API to let service providers maintain a blocked-number list. The default SMS app, the default phone app, and provider apps can read from and write to the blocked-number list. The list is not accessible to other app.
advantage of are:
- Numbers blocked on calls are also blocked on texts
- Blocked numbers can persist across resets and devices through the Backup & Restore feature
- Multiple apps can use the same blocked numbers list
For more information, see android.provider.BlockedNumberContract
Update an existing project.
To compile your app against the Android N platform, you need to use the Java 8 Developer Kit (JDK 8), and in order to use some tools with Android Studio 2.1, you need to install the Java 8 Runtime Environment (JRE 8).
Open the build.gradle file for your module and update the values as follows:
android {
compileSdkVersion 'android-N'
buildToolsVersion 24.0.0 rc1
...
defaultConfig {
minSdkVersion 'N'
targetSdkVersion 'N'
...
}
...
}
You could just re-direct specific numbers in your contacts to your voice-mail. That's already supported.
Otherwise I guess the documentation for 'Contacts' would be a good place to start looking.
You can do it by listening to phone call events . You do it by having a BroadcastReceiver to PHONE_STATE and to NEW_OUTGOING_CALL. You find there what is the phone number.
Then when you decide to end the call, this is a bit tricky, because only from Android P it's guaranteed to work. Check here.
精彩评论