views:

13620

answers:

6

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.

+1  A: 

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.

Cogsy
+3  A: 

It is Mission Impossible for the time being. Refer to Why it is impossible to intercept incoming calls on Android for the details.

an0
+1  A: 

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 ...

voss
Question is not about any such app, it is how to block incoming number programatically + in your solution how will I know what is the number?
Anurag Uniyal
It's not that hard ... if you look inside the SDK reference you will see that there is an onCallStateChangeListener() wich has to be registered in your app. Once done it will deliver you the callState wich could be one of IDLE, RINGING or OFF_HOOK. Besides that the listener will deliver you the incomingNumber ... That is the point where your action comes in place. Unfortionally the SDK won't really give you an option to drop a call, these functions are NOT public available, they are hidden in a way that there is no way to access them.
voss
+4  A: 

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 !

foryou
Even if that works, it seems a little risky to me. Your application could be broken without notice whenever the internal API changes.
Guido
A: 

Hi foryou,

I have tried the given method but I got an error:

06-19 16:58:43.382: INFO/System.out(1593): FATAL ERROR: could not connect to telephony subsystem 06-19 16:58:43.382: INFO/System.out(1593): Exception object: java.lang.ClassCastException: com.android.internal.telephony.ITelephony$Stub$Proxy

What should I do????

I think the error is in this line: telephonyService = (ITelephony)m.invoke(tm);

I dont know how to resolve it.

Please help me.I have to complete my task as soon as possible.

Thanks in Advance Nemat

Nemat
+2  A: 

There is a work around to do auto- Call Answer and Reject. Please find the detail explanation and also steps to create Call barring application-

http://prasanta-paul.blogspot.com/2010/09/call-control-in-android.html

Hope this helps!

Prasanta