I want to reject incoming in android, I have seen so many code from these links.
Android: Taking complete control of phone(kiosk mode), is it possible? How?
http://androidsourcecode.blogspot.in/2010/10/blocking-incoming-call-android.html
But I am still unable to do it, can anybody tell me in simple and easy steps how to do it?
In order to intercept your call you just have to:
1. Make a package named. com.android.internal.telephony;
2. In this package make a interface file named ITelephony.
and write this code in that interface file.
boolean endCall();
void answerRingingCall();
void silenceRinger();
Now in your class where you want to intercept the call extend that class to BroadcastReceiver
and in onReceive()
function write the following code.
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
try {
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony) m.invoke(tm);
Bundle bundle = intent.getExtras();
String phoneNumber = bundle.getString("incoming_number");
Log.d("INCOMING", phoneNumber);
if ((phoneNumber != null)) {
telephonyService.endCall();
Log.d("HANG UP", phoneNumber);
}
} catch (Exception e) {
e.printStackTrace();
}
Thats it.