private void initGesture() {
final GestureLibrary gestureLibrary = GestureLibraries.fromRawResource(
context, R.raw.gestures);
gestureLibrary.load();
gestureOverlayView
.addOnGesturePerformedListener(new OnGesturePerformedListener() {
@Override
public void onGesturePerformed(GestureOverlayView overlay,
Gesture gesture) {
ArrayList<Prediction> arrayList = gestureLibrary
.recognize(gesture);
Prediction prediction = arrayList.get(0);
if (prediction.score >= 3.0) {
if (prediction.name.equals("back")) {
Toast.makeText(context, "退出",
Toast.LENGTH_SHORT).show();
finish();
}
} else {
Toast.makeText(context, "手势不存在", Toast.LENGTH_SHORT)
.show();
}
}
});
}