Hi, I have been struggling with this one for several days, and finally managed to make a simple program (attached) that exhibits the problem.
I am developing a Human Machine Interface (HMI) program - SPLat Controls - SimpleHMI - that makes an Android device into a user interface for a separate electronic controller microcontroller board via Bluetooth. I want to allow a user to touch and hold a button and have, say, a relay on for the duration of that hold. For this purpose I am sending button_down and button_up messages to the host, when the user respectively touches and releases the button.
To recap: I need to reliably detect and act on downs and ups, in order to track if the button is currently being touched.
What is happening is that I am randomly (but not always) getting spurious up events. I touch a button, it raises a Down event, and then an up, while I am still touching. It then sometimes (during the same touch) raises another down and then finally an up when I release the button. It is not however raising multiple Click events. If I count Ups and Clicks (as the attached program does), there will be more ups than clicks.
Imagine the button controlling a robot's forward movement - the effect would be that for some touches it would move for exactly as long as I hold the button - the desired behaviour. Other times it would move momentarily and then stop. Other times it would move briefly, stop and then continue for as long as I hold the button.
I am using two devices: A Samsung Galaxy Ace 'phone and a Google Nexus 7 tablet. The problem happens more in the N7 (Android 4.1.1), with about 20% more ups being raised than clicks. It is less pronounced in the Samsung (Android 2.3.4). It also seems to happen more in the Samsung if the button is positioned a bit too low, so it overlaps the bottom of the screen.
In my real program I am using a finite state machine and a timer to allow buttons to be used in several modes (configured dynamically by commands sent from the host): Simple Click; Autorepeat; and "hold", which is the one I have been discussing above. These modes are all generated off the Down and Up events. Because I am getting spurious Up events, it also means the normal click mode produces spurious clicks.
I can't see that I am doing anything wrong. Is this a bug in Android? Has anyone encountered it before, and is there a workaround?
David Stonier-Gibson
Samsung Galaxy ACE, 2.3.4
Google Nexus 7, 4.1.1
SPLat Controls - OEM Embedded Machine Controllers
I am developing a Human Machine Interface (HMI) program - SPLat Controls - SimpleHMI - that makes an Android device into a user interface for a separate electronic controller microcontroller board via Bluetooth. I want to allow a user to touch and hold a button and have, say, a relay on for the duration of that hold. For this purpose I am sending button_down and button_up messages to the host, when the user respectively touches and releases the button.
To recap: I need to reliably detect and act on downs and ups, in order to track if the button is currently being touched.
What is happening is that I am randomly (but not always) getting spurious up events. I touch a button, it raises a Down event, and then an up, while I am still touching. It then sometimes (during the same touch) raises another down and then finally an up when I release the button. It is not however raising multiple Click events. If I count Ups and Clicks (as the attached program does), there will be more ups than clicks.
Imagine the button controlling a robot's forward movement - the effect would be that for some touches it would move for exactly as long as I hold the button - the desired behaviour. Other times it would move momentarily and then stop. Other times it would move briefly, stop and then continue for as long as I hold the button.
I am using two devices: A Samsung Galaxy Ace 'phone and a Google Nexus 7 tablet. The problem happens more in the N7 (Android 4.1.1), with about 20% more ups being raised than clicks. It is less pronounced in the Samsung (Android 2.3.4). It also seems to happen more in the Samsung if the button is positioned a bit too low, so it overlaps the bottom of the screen.
In my real program I am using a finite state machine and a timer to allow buttons to be used in several modes (configured dynamically by commands sent from the host): Simple Click; Autorepeat; and "hold", which is the one I have been discussing above. These modes are all generated off the Down and Up events. Because I am getting spurious Up events, it also means the normal click mode produces spurious clicks.
I can't see that I am doing anything wrong. Is this a bug in Android? Has anyone encountered it before, and is there a workaround?
David Stonier-Gibson
Samsung Galaxy ACE, 2.3.4
Google Nexus 7, 4.1.1
SPLat Controls - OEM Embedded Machine Controllers
Last edited: