Thursday, September 19, 2013

[android help] Handling 3 finger tap in Android


Handling 3 finger tap in Android


touchscreen - Handling 3 finger tap in Android - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
















I am using OnTouchListener to capture multitouch events for ex. a 3 finger tap , I could able to detect up to 2 fingers. i.e event.getPointerCount() returns upto 2. Even same with onTouchEvent(). Is there any other API for handling this ? I have enabled 3 finger tap detection on my test device. This is what I have done so far:



package com.example.toucheventsample;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.VideoView;

public class TouchEventActivity extends Activity implements OnTouchListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

VideoView videoView = (VideoView) findViewById(R.id.video);
videoView.setOnTouchListener(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.touch_event, menu);
return true;
}

public boolean handleTouchEvent(MotionEvent event) {
boolean handled = true;
int action = event.getAction();
int count = event.getPointerCount();
switch (action & MotionEvent.ACTION_MASK) {

case MotionEvent.ACTION_POINTER_UP:
if (3 == count) {
// handle 3 finger tap
}
break;
}
return handled;
}

@Override
public boolean onTouch(View view, MotionEvent event) {
int count = event.getPointerCount();
handleTouchEvent(event);
return true;
}
}




























There are some apps that allow you to use more than 2 fingers. Try looking for: piano apps, keyboard apps.




















default






Read more

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...