1

I want to develop an app that can save the touch gesture history into an image in Android platform.

This is the brief explanation from android developer website about touch gesture history.

"History. You can find the size of a gesture's history by calling the MotionEvent method getHistorySize(). You can then obtain the positions, sizes, time, and pressures of each of the historical events by using the motion event's getHistorical methods. History is useful when rendering a trail of the user's finger, such as for touch drawing. See the MotionEvent reference for details."

source : http://developer.android.com/training/gestures/movement.html

rheza_h
  • 13
  • 2

1 Answers1

0

The short answer: YES, it is possible. What the referenced doco describes is that when the motion events arrive at your activity, you can get the history of this one event. This is because some time may elapse before they are delivered to your Activity and Android accumulates the events for this period. You would need to pull this information out each time you receive an onTouch and store it in some data structure. Then in your onDraw method display it to the user. If you want to write the created bitmap image to file you can use

Bitmap bm2 = createBitmap();
// Do the draw commands to the bitmap here
OutputStream stream = new FileOutputStream("/sdcard/test.jpg");
/* Write bitmap to file using JPEG and 80% quality hint for JPEG. */
bm2.compress(CompressFormat.JPEG, 80, stream);

This code came from this stackOverflow question

Community
  • 1
  • 1
hack_on
  • 2,532
  • 4
  • 26
  • 30