Enable android's phone speaker in program -
i wrote app handles incoming calls , answers them automatically. want set voice phone's loud speaker , works fine on android 4 not 4.1 , 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 manifest:
<uses-permission android:name="android.permission.modify_audio_settings" />
i getting silent exception in logcat says have not modify_phone_state
permission have defined in manifest:
java.lang.securityexception: neither user 10046 nor current process has android.permission.modify_phone_state. @ android.os.parcel.readexception(parcel.java:1425) @ android.os.parcel.readexception(parcel.java:1379) @ com.android.internal.telephony.itelephony$stub$proxy.silenceringer(itelephony.java:577) @ net.farayan.android.driveranswer.autoanswerintentservice.answerphoneaidl(autoanswerintentservice.java:155) @ net.farayan.android.driveranswer.autoanswerintentservice.onhandleintent(autoanswerintentservice.java:92) @ android.app.intentservice$servicehandler.handlemessage(intentservice.java:65) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:137) @ android.os.handlerthread.run(handlerthread.java:60)
as per docs, modify_phone_state
permission not you:
allows modification of telephony state - power on, mmi, etc. not include placing calls.
not use third-party applications.
it used work on pre 2.3, changed starting @ v.2.3 , since version permission granted system apps, means either pre-installed system folder on rom or signed manufacturer using security certificate.
Comments
Post a Comment