Android Question Routing call's audio to Bluetooth or phone

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hello,

When I place a call and the Bluetooth is connected to my car, I see a button to select where to route the call's audio (car / phone).

Please, where could I find the relative values to use with the code that Erel already provided (I don't find those values on developer.android)

B4X:
Dim r As Reflector
   r.Target = r.GetContext
   r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
   Dim mode As Int
   If Value Then mode = 2 Else mode = 0
   r.RunMethod2("setMode", mode, "java.lang.int")

Many thanks
 

coslad

Well-Known Member
Licensed User
Longtime User
Hi i used the above code , but nothing happen , i added this to manifest :

B4X:
AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)

but nothing .

The only way that works for me (note 3 with KitKat) is this code :
B4X:
Dim r As Reflector
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
Dim mode As Boolean
mode=True
 r.RunMethod2("setSpeakerphoneOn", mode, "java.lang.boolean")
DoEvents
mode=False
r.RunMethod2("setSpeakerphoneOn", mode, "java.lang.boolean")

any suggestion ?
 
Upvote 0
Top