Android Kill call function

Permissions
 <uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> 






public boolean killCall() {
        try {
            // Get the boring old TelephonyManager
        TelephonyManager tm = (TelephonyManager) ctx
                    .getSystemService(Context.TELEPHONY_SERVICE);
        Class c = Class.forName(tm.getClass().getName());
        Method m = c.getDeclaredMethod("getITelephony");
        m.setAccessible(true);
        Object telephonyService = m.invoke(tm); // Get the internal ITelephony object
        c = Class.forName(telephonyService.getClass().getName()); // Get its class
        m = c.getDeclaredMethod("endCall"); // Get the "endCall()" method
        m.setAccessible(true); // Make it accessible
        m.invoke(telephonyService); // invoke endCall()

        } catch (Exception ex) { // Many things can go wrong with reflection calls
            Log.d("not kill","PhoneStateReceiver **" + ex.toString());
            return false;
        }
        return true;
    }

Comments