Make your own gesture application in ANDROID or How to use gestures in ANDROID?

By | April 5, 2011

Hi all….
In this tutorial I will teach you how to make use of Gestures in ANDROID and make your own application.
Follow the below steps exactly to get an idea of how to use gestures.

1. Make a gesture Library.
2. Add your own gestures into it.
3. Export it to your applications and use it.

It is as simple as that…
Now let’s start………………..

1. Making a gesture library.

First start your emulator with the SD CARD .
Creating an SDCARD and starting the emulator with the SDCARD is explained in this
tutorial here then you have to download the whole project from the website here that
has the output as shown below in the screenshot.

Draw some of the gestures and save it. This is important.
Then only you can reproduce it in your own application.

Now go to file explorer and pull out the gestures file under the SDCARD from the
emulator and save it anywhere on your computer.

How to export a file from the SDCARD is covered in this tutorial

Now you have the gestures library, now you can use this in your own application.
Actually steps 2 and 3 are already covered.
Now we will make our own application and use the exported gesture library.
Next create another project and name the file and copy the following
code to it.

package com.GestureTestTwo;

import java.util.ArrayList;
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 android.widget.Toast;

public class GestureTestTwo extends Activity {
private GestureLibrary gLib;
private static final String TAG = "com.GestureTestTwo";

public void onCreate(Bundle savedInstanceState) {

     gLib = GestureLibraries.fromRawResource(this,R.raw.gestures);
     if (!gLib.load()) {
          Log.w(TAG, "could not load gesture library");

    GestureOverlayView gestures = (GestureOverlayView) findViewById(;


* our gesture listener
private OnGesturePerformedListener handleGestureListener = new
OnGesturePerformedListener() {
public void onGesturePerformed(GestureOverlayView gestureView,
Gesture gesture) {
    ArrayList predictions = gLib.recognize(gesture);

     if (predictions.size() > 0) {
          Prediction prediction = predictions.get(0);
     if (prediction.score > 1.0) {

Make a folder named “raw” inside the “src” folder and drop the exported file into it.

After export the project will look like this

Main.xml for

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
    android:text="Try to draw the gesture"
    android:layout_weight="1.0" />

Manifest file for

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".GestureTestTwo"
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

Now draw same gestures that you saved in the previous project.

The above is the one that I draw and saved in the previous project in the gesture library inside the
SDCARD. However make your own and test it. Above you can see the outputs.
If the gestures you draw matches then a toast with the gesture name will be shown

Please leave your comments if you need more help.

2 thoughts on “Make your own gesture application in ANDROID or How to use gestures in ANDROID?

  1. Pingback: Using Gestures in ANDROID,A Simple example. | Coderz Heaven

  2. Hanif Ullah Khan

    How we generate the gesture folder according to our requirements?
    Need a quick reply.


Leave a Reply

Your email address will not be published. Required fields are marked *