I have several Views on an Activity which a user wants to touch quickly in succession and I capture these touches using a TouchListener
and handling Motio
Override dispatchTouchEvent and intercept all touches there, for all multi touches the pointercount is more than one.
if(ev.getPointerCount() > 1)
{
Log.d("Multitouch detected!");
ev.setAction(MotionEvent.ACTION_CANCEL);
}
This cancels the touches and clears the pressed state of the buttons without taking any further action.
For me it worked like this. I just put this line in all active styles in my app
<item name="android:splitMotionEvents">false</item>
my style for example
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:splitMotionEvents">false</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:splitMotionEvents">false</item>
</style>
I did it like this :
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
if(event.getPointerCount() > 1) {
System.out.println("Multitouch detected!");
return true;
}
else
return super.onTouchEvent(event);
}
I think you can override onTouchEvent for any view.