Problem getting a "click sound"

raytronixsystems

Active Member
Licensed User
Longtime User
Hi!

I'm having a problem that is baffling me. I had created an imageview on a panel with a bitmap of a pushbutton using the Designer in the IDE. I created a click event subroutine for the object and assigned some code to be executed in response to the click event. I ran the app and the code ran when I pressed on the imageview pushbutton graphic but I did not hear any "click sound on my Samsung Galaxy S phone running Gingerbread 2.3. Clicks always happen for my dialog boxes and text pushbuttons, etc. but not in this case.

With this in mind, I assumed that this was a normal thing and added a button view to the same panel without a graphic or text. I pressed on this test button and heard a "click" sound each and every time I pressed this new test button. OK I thought- only real buttons make a click sound so I assigned my button graphic to the button just added to the panel and tried pushing the button with the new graphic - NO SOUND!! what's going on? I had assigned the same bitmap to both pressed and unpressed and did no other configuration for this graphical button. Why did the "click" sound go away when a button is converted from text to graphical? Is there something I am missing? Need help
thx,
ray
 
Last edited:

raytronixsystems

Active Member
Licensed User
Longtime User
I found out that if in both cases in my "click" event that if I call a subroutine that immediately invokes a dialog box that I lose the click sounds from the click event. This is true for both imageviews and buttons (with or without graphics) here. My clicks came back as soon as I commented out the code that invokes a dialog box requesting the user's password.
 
Upvote 0

raytronixsystems

Active Member
Licensed User
Longtime User
Thx Erel!

I addede a slight delay via a timer and that did the trick! I started at 1000ms and tried various delay times all the way down to 1ms which still allows the "click" sound to be heard yet minimizes the delay from the click on the graphic to the display of the dialog box for the user to enter his/her password. My question now is: Why do we have to do this? I was thinking there was some sort of race condition that the Dialog Library introduced in the system but not sure. Anyways, it works and that's good enough for me! thx again for your help!
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I was thinking there was some sort of race condition that the Dialog Library introduced in the system but not sure.
There is no race condition as everything happens in the same thread. I cannot say exactly why it happens without digging quite a lot in the Android source code. The idea is to let the event handler to complete and then show the dialog. A timer of 1ms is enough as the timer also runs in the same thread.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…