get Gesture From Predictions - Android android.view

Android examples for android.view:GestureDetector

Description

get Gesture From Predictions

Demo Code


//package com.java2s;
import android.gesture.Gesture;
import android.gesture.GestureLibrary;
import android.gesture.Prediction;
import android.util.Log;
import java.util.ArrayList;

public class Main {
    public static Gesture getGestureFromPredictions(
            GestureLibrary gestureLibrary, Gesture gesture) {
        ArrayList<Prediction> predictions = gestureLibrary
                .recognize(gesture);//from   w  w w .ja v a 2s  .c  o  m

        for (int i = 0; i < predictions.size(); i++) {
            Prediction prediction = predictions.get(i);
            if (prediction.score > 1.5) {
                Log.i("tag", prediction.name);
                return gestureLibrary.getGestures(prediction.name).get(0);
            }
        }
        return null;
    }
}

Related Tutorials