Android Question Click sound on buttons unreliable

Discussion in 'Android Questions' started by Roger Daley, Apr 8, 2015.

  1. Roger Daley

    Roger Daley Well-Known Member Licensed User

    Hi All

    I have an App with a number of buttons which have the option of making a "click" sound when pressed. I have used Media Player and a sound file [7ms] to do this, however the "click" sound does not always work. It's operation is intermittent and unpredictable.
    Possibly there is a better way to use Media Player or even a better way to make a button "click".

    Any sugestions welcome.

    Regards Roger

    Sub Process_Globals
    Dim MP As MediaPlayer
    Dim  btnClick_flag  As Int

    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
    End If
    End Sub

    Sub AnyButton_Click
    If btnClick_flag = 1 Then MP.Play
    End Sub
  2. NJDude

    NJDude Expert Licensed User

    Roger Daley likes this.
  3. Peter Simpson

    Peter Simpson Expert Licensed User

    Hello @Roger Daley,
    Try this code out.
    You will need to check the 'Audio' library in your library tab

    Dim Beep As Beeper 'Place in Sub Globals 
            Beep.Initialize(1001000'Place in Activity_Create. Adjust the duration and frequency until you get the desired click sound 

    'Call in button sub whenever you want hear hear beep/click sound
    Roger Daley likes this.
  4. Roger Daley

    Roger Daley Well-Known Member Licensed User


    Thanks guys both solutions work. I went for sound pool to keep the recorded [waveform shaped] sound but Beeper opens up other possibilties for the future.

    Regards Roger
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice