我的应用程序遇到了同样的问题。设置一些接受来电的延迟(〜3000 ms)。您还需要
acceptCall()在其他线程中调用方法。
请参阅如何在Android5.0(Lollipop)中以编程方式接听来电?
new Thread(new Runnable() { @Override public void run() { acceptCall(); } }).start();private void acceptCall() { try { // Get the getITelephony() method Class<?> classTelephony = Class.forName(telephonyManager.getClass().getName()); Method method = classTelephony.getDeclaredMethod("getITelephony"); // Disable access check method.setAccessible(true); // Invoke getITelephony() to get the ITelephony interface Object telephonyInterface = method.invoke(telephonyManager); // Get the endCall method from ITelephony Class<?> telephonyInterfaceClass = Class.forName(telephonyInterface.getClass().getName()); Method methodEndCall = telephonyInterfaceClass.getDeclaredMethod("answerRingingCall"); // Invoke endCall() methodEndCall.invoke(telephonyInterface); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }


