android - Forcing microphone input when bluetooth is on -


Text after "

I have two services: Record for the first time with Bluetooth but in the second I want to do a microphone input, how to make a voice recorder by Bluetooth is always on? Thank you.

I have tried

  am = (AudioManager) getSystemService (AUDIO_SERVICE); Am.setBluetoothScoOn (wrong); Am.stopBluetoothSco (); Am.setMicrophoneMute (wrong);  

But this does not record via the microphone when Bluetooth is turned on.

You are connected to the Bluetooth device when you set the flag (self) to record from the phone Then the flag is not set (closed) Do not register Receiver only call the normal initial record () method. Check the AudioManager state inside the BroadcastReceiver and onReceive when the flag is set and start recording.

A record from the Bluetooth headset with the registration means that the code below can help you.

Record button

Here's the Bluetooth flag variable (switch)

button.setOnClickListener (New View. OnClickListener () {@Override Public Zero onClick (Final View v) {if (Bluetooth. IsChecked ()) {Toast.makeText (getApplicationContext), "Bluetooth recording", Toast.LENGTH_SHORT) .show (); Register ();} else {toast.makeText (getApplicationContext ), "Normal recording", toast.LENGTH_SHORT. Show (); normal ();}}}); Normal recording even when Bluetooth is turned on (phone MIC) **
  protected void (normal) (/)  

/ TODO Auto generated method stub (MIsRecording) {button.setText (stopRecordingLabel); MIsRecording = True; MRecorder.startRecording (); MRecording = getFile ("raw"); StartBufferedWrite (mRecording); } Other {button.setText (startRecordingLabel); MIsRecording = False; MRecorder.stop (); File wavefile = getFile ("wav"); {Try RawToWave (mRecording, waveFile); } Grip (IOE EXPRESS E) {Toast. Maketext (Media Records, E. Messagees), Toast. LNNGHHORT). Show (); } Toast. Maketext (Media Rack, "" "wavefile.getName"), Toast. Recorded in LNNGHIHORAd. Show (); }}

** Recording from Bluetooth device will connect you with a callback when the device is connected

  register secure void () {// TODO is automatically generated Method Stub I = (AudioManager) getSystemService (reference. AUDIO_SERVICE); RegisterReceiver (New BroadcastReceiver () {@Override Public Zero onReceive (reference reference, intent to mean) {Toast.makeText (Mediarec.this, "RCV inside", Toast.LENGTH_SHORT) .show (); Integer state = intent.getIntExtra (AudioManager .EXTRA_SCO_AUDIO_STATE, -1); Log.d ("tag", "Audio SCO state:" + state); if (AudioManager.SCO_AUDIO_STATE_CONNECTED == state) {/ * * Now connection * / Bluetooth was established to toast .makeText (getApplicationContext (), "onrecive inside", toast.LENGTH_SHORT) .show (); Toast.makeText (getApplicationContext (), "onrecive inside", Toast.LENGTH_SHORT) .show (); if (mIsRecording!) { Button .SetText (stop recording labe ); MISRCording = true; MRCCR. Start recording (); MRecording = getFile ("raw"); startBufferedWrite (mRecording);} other {button.setText (startRecordingLabel); MIsRecording = False; mRecorder.stop (); File wavefile = GetFile ("wav"); {try RawToWave (mRecording, waveFile);} Grip (IOE EXPRESS E) {TOST. MACTEXT (Media Rackus, E. Messages (), Toast. LNNGHHORT). Show (); } Toast. Maketext (Media Rack, "" "wavefile.getName"), Toast. Recorded in LNNGHIHORAd. Show (); } Unregistered receiver (this); Am.stopBluetoothSco (); }}}, New Interface (Audio Manager. Action_SCO_AUDIO_STATE_UPDATED)); Log D. ("Start Bluetooth", "Bluetooth is starting"); Am.startBluetoothSco (); }  

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -