background preloader

Android Developer Google

Facebook Twitter

Detecting Common Gestures. A "touch gesture" occurs when a user places one or more fingers on the touch screen, and your application interprets that pattern of touches as a particular gesture. There are correspondingly two phases to gesture detection: Gathering data about touch events. Interpreting the data to see if it meets the criteria for any of the gestures your app supports.

Support Library Classes The examples in this lesson use the GestureDetectorCompat and MotionEventCompat classes. Gather Data Capturing touch events for an Activity or View You can then do your own processing on these events to determine if a gesture occurred. Capturing touch events for a single view View myView = findViewById(R.id.my_view); myView.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { // ...

Beware of creating a listener that returns false for the ACTION_DOWN event. Detect Gestures Detecting All Supported Gestures // Called when the activity is first created. Developing an Accessibility Service. Accessibility services are a feature of the Android framework designed to provide alternative navigation feedback to the user on behalf of applications installed on Android devices. An accessibility service can communicate to the user on the application's behalf, such as converting text to speech, or haptic feedback when a user is hovering on an important area of the screen. This lesson covers how to create an accessibility service, process information received from the application, and report that information back to the user. Create Your Accessibility Service An accessibility service can be bundled with a normal application, or created as a standalone Android project.

The steps to creating the service are the same in either situation. Package com.example.android.apis.accessibility; import android.accessibilityservice.AccessibilityService; public class MyAccessibilityService extends AccessibilityService {... @Override public void onInterrupt() { } <application ... >... R.attr. Design. Key Character Map Files.