My app alerts of a near GPS point with a Beep sound. It works ok but when the phone is connected to the hands free Bluetooth of the car the sound is send by BT to the audio system of the car. If for example I am not listening the BT sound of the car and I am listening the FM radio, I cant listen any alert because this alert is sent to the car. How can I force the phone to sound the beep alert o for example the TTS speech sound alert to the external speaker as other apps like Waze, even connected to the hands free bluetooth. I have read some but is for calls objets and this is not a call phone.
Sub ForceSpeaker
Dim jo As JavaObject
jo.InitializeContext
Dim audioManager As JavaObject = jo.RunMethod("getSystemService", Array("audio"))
audioManager.RunMethod("setMode", Array(2)) 'MODE_IN_CALL
audioManager.RunMethod("setSpeakerphoneOn", Array(True))
End Sub
Ok, Thank you very much, a fast clear answer. What we'll do when you wil not be here?
Now I implement it at app and this evening I'll test it.
Thanks a lot.
I have implemented the subroutine and it works. I just write de sub forcespeaker and I called it in the Activity_create.
Now the question is how I desactivate this mode?
I dont understand but the sub for desactivate will be this? With "False" paremeter?
B4X:
Sub ForceSpeaker
Dim jo AsJavaObject
jo.InitializeContext
Dim audioManager AsJavaObject = jo.RunMethod("getSystemService", Array("audio"))
audioManager.RunMethod("setMode", Array(2)) 'MODE_IN_CALL audioManager.RunMethod("setSpeakerphoneOn", Array(False))
End Sub
or I must to create a new SUB with "False" parameter like?
B4X:
Sub DisactivateForceSpeaker
Dim jo AsJavaObject
jo.InitializeContext
Dim audioManager AsJavaObject = jo.RunMethod("getSystemService", Array("audio"))
audioManager.RunMethod("setMode", Array(2)) 'MODE_IN_CALL
audioManager.RunMethod("setSpeakerphoneOn", Array(False))
End Sub
I'd like to put a checkbox that alternate activating-desactivating this feature.