5

I'm now programming an app to give vocal feedback through internal speaker while user performing some exercises.

Now I want to add a function to record the user's heartbeat and breathe through a stethoscope plugged in the phone by a 3.5mm jack. The problem is that when I plug in the jack, the speaker won't play any sound because the phone think that earpieces were connected and the sound will be played through them.

What I want to achieve is to record the sound by a stethoscope plugged in the phone while play sound through internal speaker.

Basically I use two ways to play sound, MediaPlayer and TextToSpeech.

I searched on the internet, found these articles:

Forcing sound output through speaker in Android

want to play TTS on Bluetooth headset

What they told me to do is to add permission MODIFY_AUDIO_SETTINGS to manifest

declare variables:

MediaPlayer mediaPlayer; 
AudioManager mAudioManager;
HashMap<String, String> mHashAlarm = new HashMap<String, String>();

in OnCreate method:

mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setSpeakerphoneOn(true);
mediaPlayer = MediaPlayer.create(context, R.raw.ding);
mHashAlarm.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_MUSIC));
...
tts.speak(text, TextToSpeech.QUEUE_FLUSH, mHashAlarm);

But neither of them works.

Does anyone know how to achieve this function? Any ideas would be a lot of help. Thanks.

Community
  • 1
  • 1
Kyne H
  • 133
  • 1
  • 7
  • Have you perhaps found a solution in the while? I'd love to achieve something similar. Thank you – Dakatine Jul 07 '13 at 20:13
  • 1
    @Anal Unfortunately I still didn't find any solution. At last I used an additional phone to record sound. And since then my project is finished and I didn't dig it further. – Kyne H Jul 08 '13 at 13:10

1 Answers1

-1

Simply purchase a audio splitter...after that u get two ports plug your external mic on one and plug any speaker on another ....

Ajith
  • 1