The gesture is saved and you can begin to recognize it.
Load the gesture library from the resource file in if (MGre = = null) {LOG.E ("", "gesture"); MGre = Gesturelibraries.fromrawresource (this, r.raw.yl_yl);// There is no error in this sentence mgre.load ();} Remove the Gestureoverlayview control from the XML mgov = (Gestureoverlayview) Findviewbyid (r.id.gesture); Mgov.setgesturecolor ( Color.Black);//Gesture Color mgov.setgesturestrokewidth (15);//gesture width// Add a listener mgov.addongestureperformedlistener (this) for the Gestureoverlayview control;
Start recognition:
Identify the gesture and return a list of type prediction arraylist<prediction> gesturelist = mgre.recognize (gesture); ) > 0) {prediction PD = Gesturelist.get (0);//If the match degree is greater than 1, it is recognized, otherwise the prompt does not recognize if (Pd.score > 3) {//Determine if the name is the same as the name of the gesture library if (pd.na Me.equals ("tick")) {Intent Intent = new Intent (mainactivity.this,secondactivity.class); startactivity (Intent); Toast.maketext (Mainactivity.this, "recognized", Toast.length_short). Show (); else {toast.maketext (mainactivity.this, "Name mismatch", Toast.length_short). Show ();}} else {toast.maketext (mainactivity.this, "unrecognized", Toast.length_short). Show ();}}
Finally, don't forget to learn about tied listening:
protected void OnDestroy () {Mgov.removeongestureperformedlistener (this); Super.ondestroy ();}
Identification of Android gestures