Android- Gesture Detection, Gesture Example

Posted: September 19, 2011 in Uncategorized

below code is just example of gesture detection on android device surface, but for that here we hav “gestures” raw library file for gesture identification, so you must have some gesture library file for that

import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.Prediction;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.os.Bundle;
import android.util.Log;
import java.util.ArrayList;

public class GestureActivity extends Activity implements OnGesturePerformedListener {
    /** Called when the activity is first created. */
    private GestureLibrary gLib;
    public void onCreate(Bundle savedInstanceState) {
        gLib = GestureLibraries.fromRawResource(this,R.raw.gestures);
        if (!gLib.load()) {
            Log.i("Gesture Lib", "could not load gesture library");
        GestureOverlayView gestures = (GestureOverlayView) findViewById(;



    public void onGesturePerformed(GestureOverlayView arg0, Gesture arg1) {
        // TODO Auto-generated method stub
        ArrayList<Prediction> predictions = gLib.recognize(arg1);
        if(predictions.size() > 0)
            Prediction prediction = predictions.get(0);
            if(prediction.score > 1.0){
                Log.i("GESTURE DETECTED"+prediction.score,;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s