Android Question How to : buttons to vibrate and make sound when you press them

MiguelCZ

Member
Licensed User
Longtime User
I am making basic calculator.

I want the buttons to vibrate when you press them, right now they vibrate but they do it when I stop pressing the button not in the moment I press it. also is the same with the sound, they make sound when I stop pressing them not when I press them.


right now in my samsung phone the buttons made the default sound I will later add my own sound and I also want it to load when pressing the button not when I stop pressing it


I have downloaded other calculators from the play store and they all vibrate and make the sound when pressed not when I stop pressing/

How can I do it?


this is a small part of my code, one button:

B4X:
Sub Globals
   
    Dim Vibrate As PhoneVibrate
   
End Sub


Sub Button2_Click

    Vibrate.Vibrate(30)
   
    If EditText1.Text.Contains("ERROR") Then
        EditText1.Text = ""
    End If

    If Stat = 1 Then
        EditText1.Text = "0"
        Stat = 0
    End If

    If EditText1.Text = "0" Then
        EditText1.Text = 2
    Else
        EditText1.Text = EditText1.Text & "2"
    End If
   
End Sub


Thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…