Gesture Recognition
//package backend.snippets;
import java.util.ArrayList;
import android.gesture.Gesture;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.Prediction;
import android.widget.EditText;
import android.widget.TabHost;
import android.widget.Toast;
public class GestureRecognition {
public void gestureReco(GestureOverlayView overlay, Gesture gesture, GestureLibrary mLibrary, TabHost tabs, App a, EditText carColor)
{
ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
Toast.makeText(a, null, Toast.LENGTH_SHORT).cancel();
if (predictions.size() > 0) {
Prediction prediction = predictions.get(0);
if (prediction.score > 1.0) {
if(prediction.name.equalsIgnoreCase("right"))
{
tabs.setCurrentTab(tabs.getCurrentTab()+1);
}
else if(prediction.name.equalsIgnoreCase("left"))
{
tabs.setCurrentTab(tabs.getCurrentTab()-1);
}
else
{
carColor.setText(prediction.name);
Toast.makeText(a, prediction.name, Toast.LENGTH_SHORT).show();
}
}
}
}
}
Related examples in the same category