ITelephony.java
Creare un'interfaccia in com.android.internal.telephony
e nome come
interface ITelephony {
/**
* Demonstrates some basic types that you can use as parameters
* and return values in AIDL.
*/
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
double aDouble, String aString);
boolean endCall();
void silenceRinger();strong text
void answerRingingCall();
}
// then catch the incoming call intent and call below method
if (intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER) != null) {
number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
Toast.makeText(context, "INCOMING call catched: ", Toast.LENGTH_SHORT).show();
disconnectPhoneItelephony(mContext)
}
private void disconnectPhoneItelephony(Context context) {
ITelephony telephonyService;
TelephonyManager telephony = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
try {
Class c = Class.forName(telephony.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
SessionManager.getInstance(context).setBlockStatusAllow("BLOCKED");
telephonyService = (ITelephony) m.invoke(telephony);
telephonyService.silenceRinger();
telephonyService.endCall();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggiungere l'autorizzazione necessaria in Manifesta
fonte
2016-08-08 06:09:46
ho intercettato delle chiamate in uscita, ma incapace di capire la logica dietro le chiamate in arrivo e le loro intercettazioni citati in queste pagine. – Zubair
possibile duplicato di [Fine chiamata in Android a livello di programmazione] (http://stackoverflow.com/questions/18065144/end-call-in-android-programmatically) – Flow