I just tried it
if(state==TelephonyManager.CALL_STATE_OFFHOOK){
AudioManager am = (AudioManager) pccontext.getSystemService(Context.AUDIO_SERVICE);
am.setMode(AudioManager.MODE_NORMAL);
am.setSpeakerphoneOn(true);
MediaPlayer mp = MediaPlayer.create(pccontext, R.raw.beep);
mp.start();
}
But it does not work in MODE_NORMAL. When I tried to MODE_IN_CALLplay sound with the phone , but the caller, on the other hand, could not listen to the sound played by the receiving telephone.
source
share