Hey. I am new to android and still involved in the learning process. I am currently planning to make an application that will automatically turn on the speaker when the call is connected. Below are the codes.
audiomanager = (AudioManager) contex.getSystemService(Context.AUDIO_SERVICE);
@Override
public void onCallStateChanged(int state, String incomingNumber) {
case TelephonyManager.CALL_STATE_OFFHOOK:
am.setSpeakerphoneOn(true);
break;
}
I tested my code on Android android 2.1..sdk 7..i using audiomanager.setSpeakerphoneOn (true); and add the MODIFY_AUDIO_SETTINGS permission in the manifest, you can turn on the loudspeaker .. but it seems like it can't ... so can anyone help? thanks in advance.
source
share