0

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)
4

2 回答 2

1

根据docsMODIFY_PHONE_STATE权限不适合您:

允许修改电话状态 - 开机、mmi 等。不包括拨打电话。

不供第三方应用程序使用。

它曾经在 2.3 之前工作,但从 v.2.3 开始进行了更改,因为该版本权限仅授予系统应用程序,这意味着要么预安装到 ROM 上的系统文件夹中,要么使用制造商的安全证书与制造商签署.

于 2013-08-25T16:20:47.500 回答
0
<uses-permission android:name="android.permission.CALL_PHONE" />

将上面添加到您的清单文件中

于 2013-08-25T16:17:20.977 回答