How in the application (dialer) can I automatically answer incoming calls? I find everywhere only the call indication methods.
Below is the code that can automatically reset ( endCall() ), but for some reason the answerRingingCall() function does not want to work.
try { TelephonyManager manager = (TelephonyManager)getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE); Class c = Class.forName(manager.getClass().getName()); Method m = c.getDeclaredMethod("getITelephony"); m.setAccessible(true); ITelephony telephony = (ITelephony)m.invoke(manager); telephony.endCall(); } catch(Exception e){ Log.d("",e.getMessage()); }
answerRingingCall(), theanswerRingingCall()must be declared:android.permission.MODIFY_PHONE_STATE- Barmaley