Recognizing Gestures Android
<p>Hi I'm building an app in which the users draws a gesture on screen and then compares if the image in imageview is the same as the gesture drawn and shows a message like well done or try again now my problem is that whenever an image appears and the user draws something different than what it displays in the image it says well done how can i solve this?...anyways here's the code</p>

<pre><code>package draw.letters;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;

import android.app.Activity;
import android.content.Context;
import android.gesture.Gesture;
import android.gesture.GestureOverlayView;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.Toast;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.Prediction;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;

public class DrawlettersActivity extends Activity implements OnGesturePerformedListener {
    private SoundPool soundPool;
    private HashMap&lt;Integer, Integer&gt; soundsMap;
    private GestureLibrary gestureLib;
    int soundOk=1;
    int soundNot=2;

    ImageView ShowImage;

    public Integer[] showLetters={R.drawable.a,R.drawable.b,R.drawable.c,R.drawable.d,
        R.drawable.e,R.drawable.f,R.drawable.g,R.drawable.h,R.drawable.i
       ,R.drawable.j,R.drawable.k,R.drawable.l,R.drawable.m,R.drawable.n,
R.drawable.o,R.drawable.p,R.drawable.q,R.drawable.r,R.drawable.s,R.drawable.t
       ,R.drawable.u,R.drawable.v,R.drawable.w,R.drawable.x,R.drawable.y,R.drawable.z};

    Random r = new Random();
    public int index = 0;
    public String idGesture;

/** Called when the activity is first created. */

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);
        soundsMap = new HashMap&lt;Integer, Integer&gt;();
        soundsMap.put(soundOk, soundPool.load(this, R.raw.htc_notify_weight, 1));
        soundsMap.put(soundNot,soundPool.load(this, R.raw.buzzybuz, 1));
        gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures);

        //Loads the gesture library
        if (!gestureLib.load()) 
        {
            finish();
        }
        GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
        gestures.addOnGesturePerformedListener(this);
    }//end of OnCreate() 

    //Method to create the sounds

    public void playSound(int sound) {
        AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
        float streamVolumeCurrent = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
        float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
        float volume = streamVolumeCurrent / streamVolumeMax; 
        soundPool.play(soundsMap.get(sound), volume, volume, 1, 0, 1);
    }

    public String idImage (ImageView compara) {
    String letterGesture = null;
    switch(compara.getId()) {
    case R.drawable.a:
        letterGesture="A";
    case R.drawable.b:
        letterGesture="B";
    case R.drawable.c:
        letterGesture="C";  
    }
    return letterGesture;
    }

    public void malEscrito() {
    Toast.makeText(this, "Wrong Try Again", Toast.LENGTH_SHORT).show();
    playSound(soundNot);
    }


    public void onGesturePerformed(GestureOverlayView overlay, Gesture gestures) {
    //Calls the image to be displayed
        index= r.nextInt(26);
        ShowImage = (ImageView) findViewById(R.id.imageView1);
        ShowImage.setImageResource(showLetters[index]);
        idGesture=idImage(ShowImage);

    ArrayList&lt;Prediction&gt; predictions = gestureLib.recognize(gestures);
    if (predictions.size() &gt; 0 &amp;&amp; predictions.get(0).score &gt; 1.0)  
        {  
            String prediction = predictions.get(0).name; 
            //compares the letters with the name of the gesture  
    if ("A".equals(prediction)) {  
                Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                //index = r.nextInt(3);
                ShowImage.setImageResource(showLetters[index]);
                playSound(soundOk);
            } else if ("B".equals(prediction)) {  
                Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                //index = r.nextInt(3);
                ShowImage.setImageResource(showLetters[index]);
                playSound(soundOk);
            } else if ("C".equals(prediction)) {  
                Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                //index = r.nextInt(3);
                ShowImage.setImageResource(showLetters[index]);
                playSound(soundOk);
            } else if ("D".equals(prediction)) {  
                Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                //index = r.nextInt(3);
                ShowImage.setImageResource(showLetters[index]);
                playSound(soundOk);
            } else if ("E".equals(prediction)) {  
                Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                //index = r.nextInt(3);
                ShowImage.setImageResource(showLetters[index]);
                playSound(soundOk);
            } else if ("F".equals(prediction)) {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("G".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("H".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("I".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("J".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("K".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("L".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("M".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("N".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
              else if ("~n".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("O".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("P".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("Q".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("R".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("S".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("T".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("U".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("V".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("W".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("X".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }
             else if ("Y".equals(prediction))  
             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }  else if ("Z".equals(prediction))  

             {  
                 Toast.makeText(this,"Well Done",Toast.LENGTH_SHORT).show();
                 //index = r.nextInt(3);
                 ShowImage.setImageResource(showLetters[index]);
                 playSound(soundOk);
             }

             else 
                {
                 malEscrito();
                }

           }
         }

}
</code></pre>

<p>I there's something that you don't quite understand please let me know thanks in advance!</p>
