Since version 1.6 Android offers a library for recognition and handling of new gestures using a touch display. With the gesture builder it is possible to capture new gestures in the emulator. Gestures can be integrated into an activity like that.

GestureLibrary gLib = GestureLibraries.fromRawResource(this, R.raw.spells);
if (!gLib.load()) {
  finish();
}
  • Furthermore we need a gesture overlay in the UI:

     <android.gesture.GestureOverlayView
        android:id="@+id/gestures"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1.0" />
  • In the next step we implement an event handler for the gesture (Source: http://developer.android.com/resources/articles/gestures.html):

    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();
         }
       }
     }

Update : In Android 2.2 there is a new class GestureUtils providing some new methods for feature extraction, geometric transformation and gesture similarity comparison – for more information take a look at the class docs.

Update : I have written a tutorial for creating a sample app recognizing getures – take a look here.

More information