Reputation: 5260
I used the https://play.google.com/store/apps/details?id=com.davemac327.gesture.tool&hl=en
gesture tool and noticed that for a line which is top to bottom vertically is not able to detect as i am using the generated gesture file in my code as follows but not able to detect the vertical top to bottom line gesture detection
import java.util.ArrayList;
import android.app.Activity;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.Prediction;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.os.Bundle;
import android.widget.Toast;
public class GesturesActivity extends Activity implements OnGesturePerformedListener {
private GestureLibrary mLibrary;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
if (!mLibrary.load()) {
finish();
}
GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
}
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
String data="";
for (int i = 0; i < predictions.size(); i++) {
data=data+ "=="+predictions.get(i).name;
}
// We want at least one prediction
if (predictions.size() > 0) {
Prediction prediction = predictions.get(0);
// We want at least some confidence in the result
if (prediction.score > 1.0) {
// Show the spell
Toast.makeText(this,data+ " "+ prediction.name, Toast.LENGTH_SHORT).show();
}
}
}
}
please suggest how to perform a vertical top to bottom vertical gesture detection
Upvotes: 2
Views: 540
Reputation: 5260
There was problem with the above code which i solved by introducing
GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.setGestureStrokeAngleThreshold( 90.0f);
As the default value of the angle threashold is 40.0f because of which simple vertical gestures would be skipped so changed it to 90.0f, so finally setting the GestureStrokeAngleThreshold to a value closer to 90.0f works fine
Upvotes: 2