I am developing an application which will take gestures and convert those gestures to according text and store them in database. I want to know if there is any Android API or method for this task.
Asked
Active
Viewed 932 times
2

Suhaib Janjua
- 3,538
- 16
- 59
- 73

user3091531
- 107
- 1
- 8
-
You mean a gesture that's being made by touching the screen ? – Antoine Marques Mar 05 '14 at 14:45
-
yes, gesture using finger or pen. – user3091531 Mar 05 '14 at 15:29
1 Answers
1
You can use a GestureDetector
that generates String
when a gesture is detected.
For example use OnGestureListener
callbacks :
// From inside some Context (View, Activity, ...)
GestureDectector detector = new GestureDetector(this, new OnGestureListener() {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
gestureDetected("FLING"); // 'gestureDetected' is then a callback to invoke on 'conversion of a gesture into a string'
}
});
Then MotionEvent
have to be 'forwarded' to the GestureDetector
, for example by overriding View.onTouchEvent(MotionEvent)
:
public boolean onTouchEvent(MotionEvent event) {
return detector.onTouchEvent(event);
}

Antoine Marques
- 1,379
- 1
- 8
- 16
-
would that GestureDetector would return the string it will detect in gesture? – user3091531 Mar 05 '14 at 15:59
-
No, id doesn't work like this : it already detects basic gestures like 'fling', then a callback is invoked (see `OnGestureListener`). You can then generate the appropriate string inside the callback, see my edit above – Antoine Marques Mar 05 '14 at 16:08
-
is there any way to get gesture in text like english alphabets gestures? – user3091531 Mar 05 '14 at 16:33
-
Just change "FLING" to something else =) For non built-in gestures, you'll have to declare methods of your own. – Antoine Marques Mar 05 '14 at 16:48