package neo.one;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.Prediction;
importandroid.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.os.Bundle;
import android.widget.Toast;
public class Gestures extends Activity implementsOnGesturePerformedListener {
private GestureLibrary mLibrary;
Intent intent = new Intent();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mLibrary = GestureLibraries.fromRawResource
(this, R.raw.gesturess);
if (!mLibrary.load()) {
finish();
}
GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
}
public void onGesturePerformed
(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions =
mLibrary.recognize(gesture);
if (predictions.size() > 0) {
Prediction prediction = predictions.get(0);
if (prediction.score > 1.0) {
Toast.makeText(this,
prediction.name, Toast.LENGTH_SHORT).show();
if (prediction.name.equals("phone_dial")) {
intent = new Intent(Intent.ACTION_DIAL);
}
if (prediction.name.equals("2"))
{
intent = new Intent(Intent.ACTION_SEARCH);
}
if (prediction.name.equals("1")) {
intent.setClass(Gestures.this,Next.class);
}
startActivity(intent);
}
}
}
} |