Android Question Internal speaker, external microphone?

Avon

Member
Licensed User
Longtime User
Using the code below in a service module, I can use the phone state notifications to set the speaker on for the duration of a call from my app.

It would be great to also use an external microphone, as the disabled user hasn't much volume. However, that doesn't work, the internal microphone remains active, as does the speaker, when I plug an external microphone in.

Are there other settings which I can manipulate to enable the external microphone, without enabling an external speaker? Where can I find these settings?

B4X:
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
   Dim mytts As TTS
   'ToastMessageShow(State, True)
   If State = "OFFHOOK" Then
     rr.Target = rr.GetContext
     rr.Target = rr.RunMethod2("getSystemService", "audio", "java.lang.String")
     rr.RunMethod2("setMode", 2, "java.lang.int")
     rr.RunMethod2("setSpeakerphoneOn", True, "java.lang.boolean")
   End If
   If State = "IDLE" Then
     rr.Target = rr.GetContext
     rr.Target = rr.RunMethod2("getSystemService", "audio", "java.lang.String")
     rr.RunMethod2("setMode", 2, "java.lang.int")
     rr.RunMethod2("setSpeakerphoneOn", False, "java.lang.boolean")
     StopService("phone1_SM1") ' stop this service
   End If
End Sub
 
Top