Play audio file in android

Let's say I'm calling someone with my Android phone. Is it possible to play some kind of sound file in a call?

+3
source share
2 answers

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.

+1
source

Unfortunately, this is not possible, this is an Android security limitation.

0
source

All Articles