So i have a panel with 6 smaller panels on it. The 6 smaller panels all have radio buttons. One of the panels has 7 radio buttons for each day of the week. I can display the panels, i can reset them to whatever radio button i want, but they don't make the clicking noise like buttons do. they still work, just no audio.
i was wondering, how do you get a radio button to make the standard android click noise (like you hear after clicking a button)? I'm thinking it's some call using mediaplayer, but I do not want my own sound, I just want the standard click noise from android.
none of that helped. either it explains how to use media player to play a sound (not the android click) or how to click. I'm sure it is a simple command to call the android sound button click noise.
Thanks. That does allow a tone, but not the beep associated with the android click. It sounds completely different. So I guess my next question is, "what settings do you use in the bellow to make it sound like an android click?" Millisecs and hertz. Surely someone has done this.
B4X:
'=============================================
'beeper from audio library
Dim b As Beeper
'---------------------------------------------
'init the beeper noise
b.Initialize(300, 500) '300 milliseconds, 500 hz
'---------------------------------------------
Sub Radio8902a_CheckedChange(Checked As Boolean)
b.Beep
End Sub
A quick google search indicates there is a function; "playSoundEffect" within java. It does not appear to be available with B4A, a search shows nothing. You'll have to create your own click sound and use it for all your functions that need to click.
Thanks. That does allow a tone, but not the beep associated with the android click. It sounds completely different. So I guess my next question is, "what settings do you use in the bellow to make it sound like an android click?" Millisecs and hertz. Surely someone has done this.
B4X:
'=============================================
'beeper from audio library
Dim b As Beeper
'---------------------------------------------
'init the beeper noise
b.Initialize(300, 500) '300 milliseconds, 500 hz
'---------------------------------------------
Sub Radio8902a_CheckedChange(Checked As Boolean)
b.Beep
End Sub
A quick google search indicates there is a function; "playSoundEffect" within java. It does not appear to be available with B4A, a search shows nothing. You'll have to create your own click sound and use it for all your functions that need to click.
While it may be annoying that you can't find a method to play the specific sound you are looking for, I find it much more refreshing to find unique sounds and then play them inside the Buttton_Click subroutine.
B4X:
Sub Button_Click
sp.Play(yourSoundObject, 1, 1, 1, 0, 1)
[I]your code here[/I]
End Sub
The sound you are looking for might even be a sound file on the phone, so you just have to dig around for it and copy it into your project.
Wheretheidivides I used lagore's sound effects library to generate the same clicking noise my galaxy s2 makes when I press any button, edit text, listview, radio button .etc.
B4X:
Dim s As esClickSound
s.Initialize
s.keyclickFx(1)
Nice. Wrote a similar approach, which works without view parameter, as I needed it for within a service.
If a view is available, I guess your code is more efficient.
B4X:
'Index API Android Constant Description
' 0 1 FX_KEY_CLICK Keyboard and direction pad click sound
' 1 1 FX_FOCUS_NAVIGATION_UP Focus has moved up
' 2 1 FX_FOCUS_NAVIGATION_DOWN Focus has moved down
' 3 1 FX_FOCUS_NAVIGATION_LEFT Focus has moved left
' 4 1 FX_FOCUS_NAVIGATION_RIGHT Focus has moved right
' 5 3 FX_KEYPRESS_STANDARD IME standard keypress sound
' 6 3 FX_KEYPRESS_SPACEBAR IME spacebar keypress sound
' 7 3 FX_KEYPRESS_DELETE IME delete keypress sound
' 8 3 FX_KEYPRESS_RETURN IME return_keypress sound
' 9 19 FX_KEYPRESS_INVALID Invalid keypress sound
Sub PlaySoundEffectFromService(Index As Int)
Dim r As Reflector
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
r.RunMethod2("playSoundEffect", Index, "java.lang.int")
End Sub
And the enhanced version, which should work independent of GUI settings:
B4X:
Sub PlaySoundEffectFromServiceVol(Index As Int, Volume As Float)
Dim r As Reflector
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
r.RunMethod3("playSoundEffect", Index, "java.lang.int", Volume, "java.lang.float")
End Sub