i m using the below code to end call, but its not happening.
private void endCallIfBlocked(String callingNumber) {
try {
TelephonyManager tm = (TelephonyManager) getApplicationContext().getSystemService(getApplicationContext().TELEPHONY_SERVICE);
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony telephonyService = (ITelephony) m.invoke(tm);
telephonyService = (ITelephony) m.invoke(tm);
telephonyService.silenceRinger();
telephonyService.endCall();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
i'm failing to get 'getITelephony' object, it will throw exception. I'm using samsung galaxy s duos phone. How to block calls in this programatically