Identification of Android gestures

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.