5.
Touchscreen
●
●
●
●
●
Touchscreen is a surface (e.g., an electronic visual display) for
detecting touches within a given area
Touchscreen is made up of special materials that capture
pressure inputs and translate them into digital data
Digital data (x, y, pressure, etc) are passed to software that
process them
Some touchscreens require the use of a stylus
Touchscreens are becoming a must for many personal digital
assistants and many video games

6.
Bits of History: Air Traffic & Music
●
●
●
●
●
The concept of touchscreen is described by E.A. Johnson in
1965
Potential application in air traffic control systems proposed in
1968
First application developed at CERN (European Center for
Nuclear Research) in 1973
In the 1980's several musical sampling and synthesis systems
used light pen technology (Fairlight CMI, Fairlight CMI IIx)
HP-150 built in 1983 is one of the first touchscreen computers

9.
MotionEvent
●
●
●
On Android, digital data from touchscreens are
captured as MotionEvent objects
MotionEvent objects are created when the user
touches the device's touchscreen
MotionEvent objects are handled by the
View.onTouchEvent() method

11.
MotionEvent
●
●
●
●
On Android, digital data from touchscreens as
MotionEvent objects
MotionEvent objects are created when the user
touches the device's touchscreen
As the bare minimum each MotionEvent object
contains the x and y coordinates of the touch
MotionEvent
objects
are
handled
by
the
View.onTouchEvent() method

13.
Interface View.OnTouchListener
●
●
●
Classes the receive touchscreen events must implement
View.OnTouchListener
Two main methods to handle MotionEvents are
onTouch(View,
MotionEvent)
and
onTouchEvent(MotionEvent)
onTouch(View, MotionEvent) is used when one
OnTouchListener handles MotionEvents from
multiple views

14.
Interface View.OnTouchListener
●
●
If onTouch() or onTouchEvent() consumes a received
MotionEvent and no other component should not
about it, the method should return true
If onTouch() or onTouchEvent() does not/cannot
consume a received MotionEvent, it should return
false

16.
Development of Touch Gestures
●
●
●
●
You create your own gesture recognizer that captures
and interprets a library of touch gestures
You can also use the Android GestureBuilder
application to develop a library of touch gestures
The built gestures are saved on sdcard
Each gesture receives a name and can be subsequently
deleted or refined

17.
Problem
Use the Android GestureBuilder application to develop
gestures for handwritten letters a, b, and c. Write an
application that consumes the built gestures and toasts the
names of recognized gestures.
Source code BuiltGesturesConsumer of is here

19.
Consumption of Touch Gestures
●
To
implement
a
touch
(BuiltGesturesConsumer)
 Create a directory /res/raw
gesture
consumer

Place the gestures file you build with the Android GestureBuilder into /res/raw

The main layout of the gesture consumer must be android.gesture.GestureOverlayView

The class that consumes gestures must implement
OnGesturePerformedListener