Reputation: 495
Is it possible to receive a call and turn on the speaker programmatically in android? Went through many question on stack overflow and google but was not satisfied. Even in AutoAnswer the speaker mode is not working in Jelly Bean. Any help guys?
This is what I get in 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)
Upvotes: 2
Views: 919
Reputation: 41129
You need to add this permission to your manifest file:
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
Upvotes: 1