Dim rr As Reflector
rr.Target = rr.GetContext
rr.Target = rr.RunMethod2("getSystemService", "audio", "java.lang.String")
rr.RunMethod2("setSpeakerphoneOn", True, "java.lang.boolean")
Private Sub setSpeakerPhone(value As Boolean)
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim audioManager As JavaObject = ctxt.RunMethodJO("getSystemService", Array(ctxt.GetField("AUDIO_SERVICE")))
Dim audioManagerStatic As JavaObject
audioManagerStatic.InitializeStatic("android.media.AudioManager")
Dim originalMode As Int = audioManager.RunMethod("getMode",Null)
If value Then
audioManager.RunMethod("setMode", Array(audioManagerStatic.GetField("MODE_IN_CALL")))
Else
audioManager.RunMethod("setMode", Array(audioManagerStatic.GetField("MODE_NORMAL")))
End If
audioManager.RunMethod("setSpeakerphoneOn", Array(value))
' // restore original mode
audioManager.RunMethod("setMode", Array(originalMode))
End Sub
Mmmm....might try it laterThere seems to have been a problem with a oneplus at some time to do with the speakerphone. It may be worth trying to turn it on a second time after a delay, just to see if you can get it working. https://forums.oneplus.net/threads/automatic-speaker-phone.120044/