Android Question Making call with speaker on

raphipps2002

Active Member
Licensed User
Longtime User
There was a thread about this which offered the following code

I tried on my Samsung S4 the following but the speaker does NOT come on...Any ideas how to fix this?

B4X:
StartActivity(PCall.Call("xxxxxxxxxxx"))
               
  Dim rr As Reflector

rr.Target = rr.GetContent

 rr.Target = rr.RunMethod2("getSystemService", "audio", "java.lang.String")

 rr.RunMethod2("setSpeakerphoneOn", True, "java.lang.boolean")

thanks
 

Peter Simpson

Expert
Licensed User
Longtime User
Add the following line to your manifest file.

B4X:
     AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)

Enjoy...
 
Upvote 0

raphipps2002

Active Member
Licensed User
Longtime User
thanks so I added this as suggested..sadly no change...the speak does not come on.

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136

AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
    
AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)   
    
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

And the code is

B4X:
StartActivity(PCall.Call("xxxxxxxxxxx"))
                
                Dim rr As Reflector
                rr.Target = rr.GetContext
                rr.Target = rr.RunMethod2("getSystemService", "audio", "java.lang.String")
                rr.RunMethod2("setSpeakerphoneOn", True, "java.lang.boolean")

Phone calls but no speaker again :(

Richard
 
Upvote 0
Top