是否可以在Android中以编程方式接听电话并打开扬声器? 经历了关于堆栈溢出和谷歌的许多问题,但不满意。即使在AutoAnswer 扬声器模式在Jelly Bean中不起作用。有帮助吗?
这是我在logcat中得到的:
FATAL EXCEPTION: main
java.lang.SecurityException: Neither user 10212 nor current process has android.permission.MODIFY_PHONE_STATE.
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at com.android.internal.telephony.ITelephony$Stub$Proxy.answerRingingCall(ITelephony.java:798)
at com.example.thu.Callclass$Calllistener.onSensorChanged(Callclass.java:144)
at android.hardware.SystemSensorManager$ListenerDelegate$1.handleMessage(SystemSensorManager.java:250)
答案 0 :(得分:1)
您需要将此权限添加到清单文件中:
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />