I wrote an app that handles incoming calls and answers them automatically. I want to set voice to phone's loud speaker and it works fine on android up to 4 but not 4.1 and 4.2.
Code:
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.setSpeakerphoneOn(true);
I have required permission in my manifest:
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
I am getting a silent exception in my LogCat that says that I have not MODIFY_PHONE_STATE
permission but I have defined this in manifest:
java.lang.SecurityException: Neither user 10046 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.silenceRinger(ITelephony.java:577)
at net.farayan.android.driveranswer.AutoAnswerIntentService.answerPhoneAidl(AutoAnswerIntentService.java:155)
at net.farayan.android.driveranswer.AutoAnswerIntentService.onHandleIntent(AutoAnswerIntentService.java:92)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)