Radio button (how to get it to make clicking noise)

wheretheidivides

Active Member
Licensed User
Longtime User
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.
 

Smee

Well-Known Member
Licensed User
Longtime User
do a search for "button sound" or "sound feedback" or "button click" and you will get a wealth of information plus a load more
:icon_clap:
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
do a search for "button sound" or "sound feedback" or "button click" and you will get a wealth of information plus a load more
:icon_clap:

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.
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User



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
 
Last edited:
Upvote 0

dagnabitboy

Active Member
Licensed User
Longtime User
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.
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
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

I use "b.Initialize(30, 30)" for a keyboard "click". Have you tried different specs?
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
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.



i cant believe that this isnt avaliable. buttons click but no sound for check boxes, edit text or radio buttons?
 
Upvote 0

sterlingy

Active Member
Licensed User
Longtime User
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.

For an exhaustive collection of every sound imaginable, check Download Sound Effects | SoundDogs.com

-Sterling
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
On my galaxy s2 on android 4.0.3 makes the click noise on radio views & checkboxes.

Go to your settings, sound, volumes see if system is on if not then enable it.

Regards, Ricky
 
Upvote 0

pluton

Active Member
Licensed User
Longtime User
Ricky_D is correct.
On my Lg Optimus P500 it makes click when is my sounds enabled. It clicks on everything image view, check box, radio button...
 
Upvote 0

Gary Miyakawa

Active Member
Licensed User
Longtime User
It's odd... on my Galaxy Tab 2 I get a click sound when I click a button but nothing for a check box....

Just strange...

Gary M
 
Upvote 0

lagore

Active Member
Licensed User
Longtime User
I have uploaded a library to generate the standard android clicking sound using 'playSoundEffect' see my post in the library section.
 
Upvote 0

Djembefola

Active Member
Licensed User
Longtime User
I'm sure it is a simple command to call the android sound button click noise.

It's simple with the help of Agrahams Reflection Library:

B4X:
Public Sub PlaySoundEffect(v As View)
   Dim r As Reflector
   r.Target = v
   r.RunMethod2("playSoundEffect",0,"java.lang.int")
End Sub
 
Upvote 0

rtesluk

Member
Licensed User
Longtime User
KeypressStandard.ogg

rtesluk :icon_clap:
 

Attachments

  • KeypressStandard.zip
    3.5 KB · Views: 270
  • btn121.zip
    6.1 KB · Views: 251
Last edited:
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
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)

Have you tried this yet?

regards, Ricky
 
Upvote 0

Controller

Member
Licensed User
Longtime User
It's simple with the help of Agrahams Reflection Library:

B4X:
Public Sub PlaySoundEffect(v As View)
   Dim r As Reflector
   r.Target = v
   r.RunMethod2("playSoundEffect",0,"java.lang.int")
End Sub

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
See http://developer.android.com/reference/android/media/AudioManager.html / playSoundEffect ( 2 variants, with/without volume parameter) for details
 
Last edited:
Upvote 0
Top