手势保存了就可以开始识别了。

 

// 从资源文件中将手势库加载进来if (mGre == null) {Log.e("", "手势");mGre = GestureLibraries.fromRawResource(this, R.raw.yl_yl);// 无此句出错mGre.load();}// 从xml中取出GestureOverlayView控件mGov = (GestureOverlayView) findViewById(R.id.gesture);mGov.setGestureColor(Color.BLACK);// 手势颜色mGov.setGestureStrokeWidth(15);// 手势宽度// 为GestureOverlayView控件添加监听mGov.addOnGesturePerformedListener(this);

开始识别:

// 识别手势,返回一个类型为Prediction的列表ArrayList<Prediction> gestureList = mGre.recognize(gesture);if (gestureList.size() > 0) {Prediction pd = gestureList.get(0);// 如果匹配度大于1,表示可以识别,否则提示无法识别if (pd.score > 3) {// 判断名字是否与手势库的名字相同if (pd.name.equals("勾")) {Intent intent = new Intent(MainActivity.this,SecondActivity.class);startActivity(intent);Toast.makeText(MainActivity.this, "已识别", Toast.LENGTH_SHORT).show();} else {Toast.makeText(MainActivity.this, "名字不匹配",Toast.LENGTH_SHORT).show();}} else {Toast.makeText(MainActivity.this, "无法识别", Toast.LENGTH_SHORT).show();}}

最后别忘了解绑监听:

protected void onDestroy() {mGov.removeOnGesturePerformedListener(this);super.onDestroy();}