I am using this code:
        try {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            Class<?> c = Class.forName(tm.getClass().getName());
            Method m = c.getDeclaredMethod("getITelephony");
            m.setAccessible(true);
            com.android.internal.telephony.ITelephony telephonyService = (ITelephony) m.invoke(tm);
            telephonyService = (ITelephony) m.invoke(tm);
            // telephonyService.silenceRinger();
            telephonyService.answerRingingCall();
        } catch (Exception e) {
            e.printStackTrace();
        }
This code needs Modify_Phone_State permission which is depreciated. Any alternative way to auto answer the incoming calls?
 
     
     
    